Execution Context & Hoisting
Each function call creates an Execution Context pushed onto the Call Stack. The Global Execution Context runs first. During the creation phase, var declarations and function declarations are hoisted — var is initialised to undefined; function declarations are fully hoisted. let and const are hoisted but remain in the Temporal Dead Zone (TDZ) until their declaration line, causing a ReferenceError if accessed early.
Practice Questions4
Q1. What is the output? ```js for (var i = 0; i < 3; i++) {} console.log(i); ```
Select one answer before revealing.
Q2. What is the output? ```js console.log(foo); var foo = "bar"; ```
Select one answer before revealing.
Q3. What happens when you access a `let` variable before its declaration?
Select one answer before revealing.
Q4. What is the Call Stack in JavaScript?
Select one answer before revealing.