A closure is a function together with the variables it captured where it was defined. That is how you build counters, caches, memoisation and private state without classes.
function makeNonce(start = 0) {
let n = start;
return () => n++;
}
const next = makeNonce(5); // 5, 6, 7…Closures are also the reason a stale variable captured in a callback keeps an old value — watch for it in event handlers.