Lexical Scope in JavaScript – Beginner’s Guide

Learn by elaboration

  • Lexical Scope is the process of assigning scope for the variables/functions in the parsing phase in runtime. There are 2 phases to any language, parsing and execution.
  • When reading a variable, the compiler first checks the current scope, then the parent, then the parents parent until it hits global scope, which, if there is no definition of the variable/function, an error is thrown.

📇Additional Metadata