Javascript, how does setInterval work?
I have a piece of javascript:
<script>
var i=1;
while(i<10){
setInterval(function(){
alert(i);
},1);
i++;
}
</script>
It creates alert boxes all reading 10 instead of 10 alert boxes from 1 to
10. What does setInterval do?
No comments:
Post a Comment