🔰scope chain

JSconceptsscope ⟩ scope chain

when a module/function/block is defined, a new scope is created. The positioning of scopes nested inside one another creates a scope hierarchy called the scope chain.

The scope of a code block can reach all its parent's lexical environment so it can use its parent’s variable(s). In this way, we have a scope chain, chain of all parent’s scope.

Last updated