block scope
2022年5月1日小于 1 分钟
block scope
Question
What does the code snippet to the right output by console.log
?
Snippet
for (var i = 0; i < 5; i++) {
setTimeout(() => console.log(i), 0)
}
for (let i = 0; i < 5; i++) {
setTimeout(() => console.log(i), 0)
}