Hoisting: JavaScript moves variable and function declarations to the top of their scope during the compilation phase.
TDZ (Temporal Dead Zone): The time between entering a scope and the variable's declaration, during which accessing a let or const variable throws a ReferenceError.
| Keyword | Hoisted | Initialized | TDZ |
|---|---|---|---|
var | ✅ | undefined | ❌ No TDZ |
let | ✅ | ❌ | ✅ Exists |
const | ✅ | ❌ | ✅ Exists |
| function declaration | ✅ Fully | ✅ | ❌ No TDZ |