+ 3
I don't understand this challenge in Javascript.
I don't get why the output of the following code in JavaScript is 333. Could anyone explain it please? for(var i=0; i<3;i++){ setTimeout(function(){ document.write(i);} ,200); }
4 Answers
+ 4
maybe Timeout capture last value of i, and execute 3 times, because the "for" is executed before of timeout function
+ 2
That's what I thought but I am not sure
+ 2
I tried it in google chrom it seems your guess is accurate. But it is very strange.