How does the lexical scoping mechanism work in JavaScript?

  • It allows functions to access variables defined in their caller's scope.
  • It restricts variables to the global scope only.
  • It enforces strict mode in JavaScript.
  • It determines the order of function execution.
Lexical scoping in JavaScript allows functions to access variables from their containing or parent scopes. This means that inner functions can access variables defined in outer functions, but not vice versa. The other options do not accurately describe lexical scoping.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *