/Execution Context & Hoisting
Concept Detail

Execution Context & Hoisting

Difficulty: medium

Overview


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 Linked Questions


medium

Q1. What is the output? ```js for (var i = 0; i < 3; i++) {} console.log(i); ```


Select one answer before revealing.

medium

Q2. What is the output? ```js console.log(foo); var foo = "bar"; ```


Select one answer before revealing.

medium

Q3. What happens when you access a `let` variable before its declaration?


Select one answer before revealing.

medium

Q4. What is the Call Stack in JavaScript?


Select one answer before revealing.