Lexical Environment - archering/basic GitHub Wiki

Lexical Environment To understand what’s going on, let’s first discuss what a “variable” actually is.

In JavaScript, every running function, code block, and the script as a whole have an associated object known as the Lexical Environment.

The Lexical Environment object consists of two parts:

1.Environment Record – an object that has all local variables as its properties (and some other information like the value of this).

  1. A reference to the outer lexical environment, usually the one associated with the code lexically right outside of it (outside of the current curly brackets).

So, ** a “variable” is just a property of the special internal object, Environment Record**. “To get or change a variable” means “to get or change a property of the Lexical Environment”.