Language concepts

Binding shadowing

Try the free JavaScript compiler

A declaration in a nested lexical scope can hide an outer binding of the same name. The two bindings remain distinct. Assigning to the nearest binding does not automatically change the outer one. Duplicate lexical declarations within one scope are different and may be syntax errors.

Formal Syntax & Structure

javascript syntaxjavascript
let name = 1; { let name = 2; }

Working Example

Example Snippetjavascript
const level = 1;{ const level = 3; console.log(level); }console.log(level);
JavaScript Reference