Lexical Scope
Noun · Development
Definitions
A scoping rule in which a variable's visibility is determined by its position in the source code at write time — an inner function can access variables from its enclosing function because scope is resolved by the nesting structure of the code, not by the call stack at runtime (which would be dynamic scope).
In plain English: A rule that says a piece of code can use variables from the surrounding code where it was written, not from wherever it happens to be called.
Example: "Closures work because of lexical scope — the inner function captures the variable from where it was defined, not where it's called."