4.2 Lexical environments
In the JavaScript language specification, scopes are “implemented” via lexical environments. They consist of two components:
An environment record that maps variable names to variable values (think dictionary). This is the actual storage space for the variables of the scope. The name-value entries in the record are called bindings.
A reference to the outer environment – the environment for the outer scope.
The tree of nested scopes is therefore represented by a tree of environments linked by outer environment references.