I have a very trivial
question. For a simple loop with setTimeout, like
this:
for (var count = 0; count
< 3; count++) {
setTimeout(function() {
alert("Count = " +
count);
}, 1000 *
count);
}
console
gives an output like this:
Count =
3
Count = 3
Count =
3
Not sure why the
output like this. Anyone could explain, please?
No comments:
Post a Comment