jQuery source功能使用 setTimeout
并将 0
和 1
作为第二个参数。我的印象是它们的意思都是“尽快执行该函数”。
这是正确的吗?两者有区别吗?
最佳答案
setTimeout
的最小超时时间为 4 毫秒。所以两者实际上没有区别。
If the currently running task is a task that was created by the setTimeout() method, and timeout is less than 4, then increase timeout to 4.
编辑:正如艾哈迈德在评论中指出的那样,规范现在已经改变,所以目前的答案是“这取决于情况。”
关于javascript - setTimeout(fn, 0) 和 setTimeout(fn, 1) 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8341803/