Namaste JavaScript — Interview Quick Notes
Ep 8: let, const & Temporal Dead Zone
- let and const are block-scoped and stored in a separate memory space (not on window).
- TDZ = the time between hoisting and the line where the variable is initialised. Accessing in TDZ → ReferenceError.
- let can be declared and assigned separately; const must be initialised at declaration.
- Re-declaring let in the same scope → SyntaxError. Reassigning const → TypeError.
- Best practice: prefer const > let > avoid var.