Output: var in a for loop with setTimeout, then the same loop with let
EasyP1Output
What does this code print?
1for (var i = 0; i < 3; i++) {2 setTimeout(() => console.log('var', i), 0);3}45for (let j = 0; j < 3; j++) {6 setTimeout(() => console.log('let', j), 0);7}
Saved automatically
One line per console.log. Arrays as [1, 2, 3], objects as { a: 1 }, an uncaught error as Uncaught TypeError: message (Chrome and Node wording).
Hints
Saved automatically