When JavaScript encounters an identifier, it must determine which variable binding that name refers to. The running execution context performs this lookup through its lexical environment. section 5.3
Lookup follows the nested structure of the code:
- Check the current lexical environment for the identifier. section 5.4.2
- If it is not there, check outer environments in turn until a binding is found. section 5.4.2
Following the lookup
In the nested report and skulk example, intro is found in report’s environment, action in the outer skulk environment, and ninja in the global environment. section 5.4.2
Trace how variable lookup moves through lexical environments to find a matching binding. section 5.4.2
