Running the following code in the console:
for (var i = 0; i < 5; i++) {
let j = i;
setTimeout(function(){
console.log(j);
}, 0)
}
results in some strange behavior. When I run it once, I see something like:
What is that number at the top?
9 // what is this????
0
1
2
3
4
The next time I run it, it's different:
13 // what is this????
0
1
2
3
4