|
|
|
|
|
by sapiogram
436 days ago
|
|
No, that's a mistake in the article. The variable is still captured by reference, but `let` is causing it to be re-declared on every iteration of the loop, not mutated. The following code prints 1, 2, 3. It wouldn't do that if the variable was captured by value. for (let i = 0; i < 3;) {
setTimeout(() => console.log(i));
i++;
}
|
|