Key Points About JavaScript Closures
- 1. A closure is created when a function is defined within another function and the inner function needs to
access variables in the outer function's scope.
- 2. Closure helps to achieve lexical scope from child function to parent function.
- 3. Closure preserves the state of the parent function even after its execution is completed.
- 4. A child function will have a reference to the closure.
- 5. Every time a parent function is called, a new closure is created.
- 6. Disadvantage: High memory consumption.