A closure is a function that remembers its outer scope variables even after the outer function has finished executing.
function outerFunction() { let count = 0; return function innerFunction() { count++; console.log(count); }; } const counter = outerFunction(); counter(); // 1 counter(); // 2
codification school Changed status to publish November 29, 2024