GitHubSign in

In JavaScript, the Lexical Environment is a place where identifiers lives or are physically present during the program execution. \nTechnically, It is an internal hierarchical data structure of the JS engine that hold identifier-variable mapping. It consists of two main components: the environment record and a reference to the outer environment.\n

"When a function is executed, a new Execution Context is created, when an Execution Context is created, a Lexical Environment is created.\n\nVariables declared with 'var' are hoisted to the top of their enclosing lexical environment.\n\nThe Lexical Environment is a key part of understanding how variable and function scope works in JavaScript."