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.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in What Is a Closure in JavaScript?
Still have questions?
Browse all our FAQs or reach out to our support team
