This chapter introduces variable scope, an important foundational
term “binding” refers to the act of assigning a value to a name in
var assignment, function
this passing, and property
assignment. This chapter first touches on dynamic scoping, as displayed in
this reference, and proceeds
onto function-level scoping and how it works. All of this builds up to a
discussion of closures, or functions that capture nearby variable bindings
when they are created. The mechanics of closures will be covered, along with
their general use cases and some examples.
The value of the
The execution context defined by the value of the
The “lifetime” of a variable
The variable value resolution scheme, or the lexical bindings
The extent of a scope refers to the lifetime of a variable (i.e., how long a variable holds a certain value). I’ll start with variables with the longest lifespan—that of the “life” of the program itself—globals.