Its execution context. Parameters, var declarations (function-scoped), let/const (block-scoped), and inner function declarations form the local scope. Each call gets its own.
Function Execution Context and Local Scope
What defines a function's local scope in JavaScript?
The answer
More FAQs in Function Execution Context and Local Scope
No. Each recursive call creates its own execution context and local scope. Each call has its own copy of parameters and local variables, which is why recursion works correctly.
Through the outer environment reference in its execution context. This forms the scope chain. If a variable is not found locally, the engine walks up the chain to the lexical parent.
Yes, if it returns an inner function that captures the local scope. This is a closure. The variable environment stays alive as long as the inner function exists.
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.