I see in some question What is minimum millisecond value of setTimeout? people talk about the "minimal timeout of setTimeout", but I can't really understand it.
It says the minimal timeout value in HTML5 spec is 4ms
, so I think, if I run following code in browsers (say Chrome):
setTimeout(function() { console.log("333"); }, 3);
setTimeout(function() { console.log("222"); }, 2);
setTimeout(function() { console.log("111"); }, 1);
setTimeout(function() { console.log("000"); }, 0);
the output should be:
333
222
111
000
But actually it is:
111
000
222
333
Seems like they still be run according to the specified timeout even if they are less than 4 (expect the 0
and 1
)
How should I understand the value 4ms
?