“What are closures in JavaScript? How do they function?
Closures allow inner functions to access outer function’s variables even after outer function execution.
Example: function outer() { let x = 10; return function inner() { console.log(x); } } const innerFunc = outer(); innerFunc(); // Output: 10”
New contributor
RealMan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.