Skip to content

Hoisting

Hoisting is JavaScript’s behavior of moving declarations (but not assignments) to the top of their scope during the compilation phase.

  • Understand how var, let, const, and function are hoisted differently
  • Explain the Temporal Dead Zone (TDZ)
  • Write code that avoids hoisting confusion
flowchart TD
A["JavaScript Code"]
B["Compilation: Memory Allocation"]
C["Execution"]
A --> B --> C
B --> D["function: Fully hoisted"]
B --> E["var: Declared + initialized as undefined"]
B --> F["let/const: Declared, NOT initialized (TDZ)"]
B --> G["class: NOT hoisted"]
TopicDescriptionEst. Time
Function HoistingHow function declarations are hoisted10 min
var HoistingHow var declarations are hoisted10 min
let/const HoistingTDZ and block scoping15 min
Temporal Dead ZoneThe TDZ explained in detail10 min
  • Execution context basics
  • Variable declarations with var, let, const
  • Function declarations vs expressions
Function Hoisting → var Hoisting → let/const Hoisting → Temporal Dead Zone