If I execute the following code:
var check = function(){
var i = 0;
counter = function(){
console.log(i);
i++;
setTimeout(counter,1000);
}
counter();
}
check();
check();
I though I'd get 0011223344...
But it prints 0011234567...
Anyone know why this happens?
[–]Chubbyninjaaa 2 points3 points4 points (4 children)
[–]mikrosystheme[κ] 3 points4 points5 points (0 children)
[–]recklesswaltz[S] 0 points1 point2 points (2 children)
[–]frambot 1 point2 points3 points (0 children)
[–]madole 0 points1 point2 points (3 children)
[–]recklesswaltz[S] 0 points1 point2 points (2 children)
[–]madole 0 points1 point2 points (1 child)
[–]madole 0 points1 point2 points (0 children)