example of closure
Example: js closure examples
function outer() {
var counter = 0; // Backpack or Closure
function incrementCounter() {
return counter++;
}
return incrementCounter;
}
const count = outer();
count(); // 0
count(); // 1
count(); // 2