Predict the output. Explain the why.
Original interview-style JavaScript puzzles. Choose an answer to reveal the mental model and connect the explanation to an existing lesson.
Answers are checked against authored fixtures. Code is shown for reasoning; this page does not execute user-provided snippets.
Question 1 of 104beginner · Closures and timers
A loop with var
What does this print after the timers run?
for (var i = 0; i < 3; i++) {
setTimeout(() => console.log(i), 0);
}