JavaScript · Junior · Question 7 of 75

What does this code print?

console.log(y);
let y = 5;

Explanation

let and const are hoisted too, but until the declaration line they're in the temporal dead zone (TDZ): any access throws a ReferenceError. This helps catch variables used before initialization.

Further reading

Problem with a question

JavaScript · Junior · question 7

Test yourself

Take the JavaScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz