Where in the ECMAScript specification can we find text that describes exactly when a new Lexical Environment is created?
- I could not find it in "8.1 Lexical Environments", which just loosely states:
Usually a Lexical Environment is associated with some specific syntactic structure of ECMAScript code such as a FunctionDeclaration, a BlockStatement, or a Catch clause of a TryStatement and a new Lexical Environment is created each time such code is evaluated.
- From "8.3 Execution Contexts", we know every execution context contains a Lexical Environment, but we do not know exactly when new execution contexts are created, and indeed if there are other situations where Lexical Environments are created. 8.3 only states:
New execution context is created whenever control is transferred from the executable code associated with the currently running execution context to executable code that is not associated with that execution context.
I'm trying to understand the behavior of JavaScript implementations, solely based on information from the official ECMAScript specification. Thus, I try to avoid any terms not defined therein (such as scope).