JavaScript · Junior · Question 6 of 75
What does this code print?
console.log(x);
var x = 5;- ✓Correct answer:
undefined - 2
5 - 3
ReferenceError
Explanation
The var declaration is hoisted to the top of the function and initialized with undefined, while the assignment stays in place. With let or const this would be a ReferenceError.