$ ./guess_the_languageProblem Solving — predict the output
Problem Solving — predict the output · hard · #40

What is logged?

for (let i = 0; i < 3; i++) {
  setTimeout(() => console.log(i), 0);
}
  1. 0 1 2
  2. 3 3 3
  3. 0 0 0
  4. 1 2 3
let creates a fresh binding per iteration, logging 0 1 2.
Play Problem Solving ▸