this example is given in official documentation of typescript but I cant understand it.
for (var i = 0; i < 10; i++) {
setTimeout(function() { console.log(i); }, 100 * i);
}
ouptput of this snippet is:
10
10
10
10
10
10
10
10
10
10
this example is given in official documentation of typescript but I cant understand it.
for (var i = 0; i < 10; i++) {
setTimeout(function() { console.log(i); }, 100 * i);
}
ouptput of this snippet is:
10
10
10
10
10
10
10
10
10
10