Code
Loading editor...
Tap Analyze to see visualization
Click Analyze to visualize
See step-by-step execution, variables, and output
Variables
Run code to see variables
Output
Console output will appear here
Click Analyze to visualize
See step-by-step execution, variables, and output
Run code to see variables
Console output will appear here
Nest functions to demonstrate lexical scope chain lookup. The inner function accesses its own variables, then the enclosing outer function variables, then global variables. Variable shadowing shows that a local declaration hides the outer variable of the same name without modifying it.
JavaScript resolves variable references by walking outward through the lexical scope chain, stopping at the first match. Shadowing creates a new binding in the inner scope, leaving the outer binding untouched.
Updated Feb 2026