1 Closures & scope
A closure is a function that remembers variables from where it was created — the basis of data privacy and factories.
function counter() {
let n = 0;
return () => ++n;
}
const next = counter();
console.log(next(), next(), next());