Lexical scoping resolves variables from the static nesting of declarations. It supports interview reasoning about execution contexts, scope chains, closures, hoisting, and runtime context. section 3.1
Use lexical scoping to:
- Explain variable-resolution questions involving hoisting and the Temporal Dead Zone. section 3.1
Persistent closure state
An outer function initializes count and returns an inner function. Repeated calls to the returned function produce 1, 2, and 3 because the inner function retains access to count.
