Scope is the region of program text where a variable or function name refers to a particular declaration. JavaScript looks in the closest surrounding scope first, then moves outward through parent and global scopes. section 2.4
Functions retain access to surrounding bindings through lexical scope. This closure behavior lets returned functions use parameters and local variables after the outer function finishes, supporting private variables, callbacks, and higher-order functions. section 2.4
JavaScript scope behavior includes:
- Block-level scope prevents loop and conditional bindings from leaking into surrounding code, avoiding ambiguous counters and related bugs. section 2.4
A returned function remembers its scope
makeAddFunction(10) returns add, which still uses amount when called later; addTenTo(10) produces 20.




















