How does a closure work in JavaScript?
Lexical scope means the scope chain is fixed at write time. When a function is defined inside another, it gets an outer reference to the outer function's environment. That reference travels with the function object, even after the outer function returns.
Explore This Question
Search for additional explanations using these tools:
More FAQs in What Is a Closure in JavaScript?
Still have questions?
Browse all our FAQs or reach out to our support team
