IT lexicon › Programming › Scope

Scope

Programming På svenska → Updated: 2026-07-30

Where in the code a variable is visible — block scope, function scope, global scope.

let and const are block-scoped in JS; the old var is function-scoped (confusing). Lexical scope = determined by where the code lives; dynamic scope (bash) = determined by who calls it. Closures capture scope for later use.

← Back to the lexicon