Hoisting is JavaScript's default behavior during the compilation of moving declarations to the top of their scope before execution.
What exactly gets hoisted?
✔ 1. Variable declarations
var→ hoisted and initialized withundefinedlet&const→ hoisted but not initialized (Temporal Dead Zone)
✔ 2. Function declarations
- Fully hoisted (you can call them before declaration)
✔ 3. Class declarations
- Hoisted but behave like
let/const(TDZ applies)