Skip to main content
๐Ÿ”ฎ Output PredictionJS JavaScript Hard+35 XP

Closure Trap

What does this log?

JavaScript
for (var i = 0; i < 3; i++) {
  setTimeout(() => console.log(i), 0);
}
// Output after all timeouts:

๐Ÿ”ฎ What is the output?

Priygop - Leading Professional Development Platform | Expert Courses & Interview Prep