Question
What will be the output?
for(var i=0;i<3;i++){
setTimeout(()=>console.log(i),0)
}
Answer
Output: 3 3 3
var has function scope, so all callbacks share the same variable reference.
Key Points
This question tests your understanding of JavaScript internals and execution behavior. Interviewers often ask similar variations to evaluate debugging and reasoning skills.