Scope

noun

say it: “SKOHP” /skoʊp/

The part of a program where a variable can be seen and used; outside that part, JavaScript says the name is not defined.

What is Scope in JavaScript?

Scope — Where in the code a variable can be used.

const taxRate = 0.08;

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

In a sentence

  • “The tip variable was made inside the function, so its scope ends at the function's closing brace.”

Level: Apprentice · More JavaScript terms at this level

Updated

In other subjects