Lexical Scope

The rule that a function can use names from where it was written.

What is Lexical Scope in JavaScript?

Lexical Scope — The rule that a function can use names from where it was written.

const taxRate = 0.08;

function addTax(price) {
    const tax = price * taxRate;
    return price + tax;
}

Level: Journeyman · More JavaScript terms at this level

Updated