A scope chain links a function’s execution context to its parent context, allowing an inner function to access its outer function’s closure. The chain eventually reaches the global context. It is not the same as an object’s prototype chain: scope concerns lexical access, while prototypes concern object inheritance. section 7.1
Nested functions and currying
A curried logger transforms one function with several parameters into nested functions: logger(appender)(layout)(name)(level)(message). Each nested call creates a function context and preserves links through the scope chain. This supports sequential argument application but increases the number of active stack frames. section 7.1
Figure 7.2. When invoking any function, like logger in this case, the single-threaded JavaScript runtime pauses the current global context and activates the context for the new function to run. At this point, a link is created between the global context and the function context, traversable via the scopeChain. Once logger returns, its execution context is popped off the stack, and the global context resumes.
Follow the context link created when a function runs: the current context pauses, the function context activates, and the global context resumes after return. section 7.1
