Variable/function declarations are moved to the top of their scope during compilation phase.
Solution Code
JavaScript
console.log(x); // undefined
var x = 5;
Explanation
Only declarations are hoisted, not initializations. Works differently for let/const.Guided Hints
Try accessing variable before declaration
Difference between var and let/const