Closures allow a function to access variables from an enclosing scope even after it leaves the scope in which it was declared.
Source Code
function makeCounter() {
let count = 0;
return function() {
return count++;
};
}
let counter = makeCounter();
console.log(counter()); // 0
console.log(counter()); // 1