Namaste JavaScript — Interview Quick Notes
Ep 9: Block Scope & Shadowing
- A block { } groups statements. let/const inside a block are scoped to that block; var leaks to the enclosing function/global scope.
- Shadowing: a same-named inner variable shadows the outer one within its scope.
- var shadowing another var modifies the same memory — the outer value is overwritten.
- let shadowing let (or var) creates a separate memory slot — the outer is unaffected.
- Illegal shadowing: shadowing a let with var in the same scope → SyntaxError.