Closure

An inner function that remembers the variables around it.

What is Closure in JavaScript?

Closure — An inner function that remembers the variables around it.

function createCounter() {
    let count = 0;
    return () => ++count;
}

Level: Journeyman · More JavaScript terms at this level

Updated