[英]setTimeout and scheduling of the function call
Given the following code, when will function go
be executed? 考虑下面的代码,当将函数go
执行?
setTimeout(go, 0);
Will it be added to the end of the Job Queue immediately, or added to the end of the Job Queue after the minimum interval for setTimeout
? 它会立即添加到作业队列的末尾,还是在setTimeout
的最小间隔后添加到作业队列的末尾?
Most browsers implement a minimum delay time of 4ms. 大多数浏览器的最小延迟时间为4ms。 You can use lower values without error, but when actually executing the script, the browser will overwrite the timeout value. 您可以使用较低的值而不会出现错误,但在实际执行脚本时,浏览器将覆盖超时值。
https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setTimeout?redirectlocale=en-US&redirectslug=DOM%2Fwindow.setTimeout#Minimum.2F_maximum_delay_and_timeout_nesting https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setTimeout?redirectlocale=en-US&redirectslug=DOM%2Fwindow.setTimeout#Minimum.2F_maximum_delay_and_timeout_nesting
https://html.spec.whatwg.org/multipage/webappapis.html#timers https://html.spec.whatwg.org/multipage/webappapis.html#timers
如果超时为0,则会立即将其添加到作业队列的末尾
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.