lexical environment optimizaton

🚧 under construction

JSconceptsscopelexical environment ⟩ JS engine optimization

replit:lexical environment: optimization

let value = "Surprise!";

function f() {
    
    // ⭐ `value` never used by `g`.
    // ⭐ v8 will optimize it out from the "lexical environment"!
    // ⭐ it's not accessable in the "debugger".
    let value = "the closest value";

    return function g() {
        // ⭐ in "console": type `alert(value)`.
        debugger;         // ❗ Surprise!
    }
}

let g = f();
g();

Last updated

Was this helpful?