Lexical Scope
Overview of lexical scope in JavaScript.
We'll cover the following
Background
There are two types of scopes: global and local. We have yet to explore exactly how local scopes draw boundaries between themselves. Additionally, JavaScript has some features that allow inner scopes to access values from the outer scope.
Introduction
Lexical scope is the ability for a function scope to access variables from the parent scope. We call the child function to be lexically bound to the parent function. The diagram below outlines the supposed hierarchy that the lexical scope maintains in JavaScript.
Get hands-on with 1400+ tech skills courses.