Question
What will be the output?
console.log(a);
var a = 10;
Answer
Output: undefined
Variables declared with var are hoisted to the top of their scope. Only the declaration is hoisted, not the assignment.
Key Points
This question tests your understanding of JavaScript internals and execution behavior. Interviewers often ask similar variations to evaluate debugging and reasoning skills.