Define Closure ?
- A closure in JavaScript is the combination of a function bundled together with references to its surrounding state, known as the lexical environment. Essentially, a closure allows an inner function to "remember" and access variables from its outer (enclosing) scope even after the outer function has finished executing
- Closures make it possible for a function to have "private" variables
a lexical environment is the internal structure that keeps track of:
- Variables and function declarations available in the current scope
- A reference to the outer (parent) environment
- It’s the foundation of how scope and closures work


Top comments (0)