Global, Function and Block Scope — a practical guide to JavaScript global function block scope with clear examples you can reuse in real projects.
JavaScript Tutorial Series (48/101). Prefer one article? Read the complete JavaScript tutorial.
Short description
Blocks ({ }) create scope for let/const.
Block scope
if (true) {
let x = 1;
}
// x is not visible here