🔰lexical environment

JSconceptexecution context ⟩ lexical environment

// make counter
function Counter() {

    let count = 0;

    return function() {
        return ++count;
    };
}

// a counter instance
let counter = Counter();

counter(),    // 1
counter(),    // 2

Last updated

Was this helpful?