A scoping rule where the accessibility of variables is determined by where they are declared in the source code, creating nested scopes based on the program's structure. Inner scopes can access variables from outer scopes.
From Greek 'lexikos' meaning relating to words or vocabulary, combined with 'scope' from Greek 'skopein' meaning to look or examine. The term emphasizes that variable visibility is determined by the text structure of the program.
Lexical scoping is like Russian nesting dolls - each inner doll can see and use everything from the outer dolls that contain it, but outer dolls can't peek inside! This predictable rule means you can figure out what variables are available just by looking at the code structure.
Complete word intelligence in one call. Free tier — 50 lookups/day.