javascript setTimeout 是否保证触发 [英] is javascript setTimeout guaranteed to fire
问题描述
我读过这篇文章:http://ejohn.org/blog/how-javascript-timers-work/一>我知道如果页面太忙 setInterval 可能会放弃一些回调执行.
I've read this article: http://ejohn.org/blog/how-javascript-timers-work/ and I understand that setInterval might drop some callback execution if the page is too busy.
我不知道这如何也适用于 setTimeout,因此假设 setTimeout 将始终执行(可能有一些延迟)是否安全,或者是否是由于进程繁忙而丢弃 setTimeout 的情况?
I don't see how this would apply to setTimeout too, so is it safe to assume that setTimeout will always be executed (possibly some delay), or is it a case where a the setTimeout is dropped because of a busy process?
推荐答案
是的.传递给 setTimeout
的函数将在某个时刻执行.虽然不能保证其时间.
Yes. A function passed to setTimeout
will execute at some point. While its timing is not guaranteed.
这篇关于javascript setTimeout 是否保证触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!