Local Scope

noun

say it: “LOH-kul skohp” /ˈloʊkəl skoʊp/

The inside of one function or block: a variable made there belongs only to that area and can't be seen from outside it.

What is Local Scope in JavaScript?

Local Scope — A function or block scope where declarations are available only inside that area.

const taxRate = 0.08;

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

In a sentence

  • “Each call gets its own discount variable, because it lives in the function's local scope.”

Level: Apprentice · More JavaScript terms at this level

Updated