I just want to know why setInterval()
and setTimeout()
not matching time result ?
Syntax :
setInterval(code,millisec,lang)
setTimeout(code,millisec,lang)
and both using millisecond..
Why I get random i
all the time ?
So my test function look like...
var i = 0;
$("button").click(function() {
var run = setInterval(function(){
i++; $("code").html(i);
},0);
setTimeout(function(){
clearInterval(run);
i = 0;
},2000);
});
Why result not showing 2000 ? or what I misunderstand something ?
If min. value for setInterval()
is 4ms why I don't get same result ?
Playground : http://jsbin.com/ezeliz/1/edit