Predict the output of the following javascript code
for (var i = 0; i < 3; i++) {
setTimeout(() => console.log(i), 1);
}
for (let i = 0; i < 3; i++) {
setTimeout(() => console.log(i), 1);
}
Quiz Explanation
Because of the event queue in JavaScript, the setTimeout callback function is called after the loop has been executed.