+ 1
Can't understand a question from challenge.
Hi. Can anyone explain me why is output 333? for(var i = 0; i < 3; i++) { setTimeout (function() { document.write(i) } , 200); } Thanks.
2 Answers
+ 5
that call 3 time setTimeout(...) .
but delay time is 200ms, for is ended and i have 3 value.
therefore 3 time printed 3 and result is 333.
0
but why for ends when there's something to do, I mean why don't loop waits until setTimeout's end?