What is lexical scoping in JavaScript?

  • A type of error handling in JavaScript
  • A scoping mechanism in JavaScript
  • A method to declare global variables
  • A JavaScript data type
Lexical scoping in JavaScript refers to the way variable scope is determined by the placement of variables in the source code. Variables declared inside a function are accessible within that function, creating a hierarchy of scope. This helps prevent variable conflicts and promotes clean code.
Add your answer
Loading...

Leave a comment

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