gpt4 book ai didi

javascript - setTimeout(fn, 0) 和 setTimeout(fn, 1) 有什么区别?

转载 作者:行者123 更新时间:2023-12-03 21:30:50 31 4
gpt4 key购买 nike

jQuery source功能使用 setTimeout 并将 01 作为第二个参数。我的印象是它们的意思都是“尽快执行该函数”。

这是正确的吗?两者有区别吗?

最佳答案

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.

Spec

编辑:正如艾哈迈德在评论中指出的那样,规范现在已经改变,所以目前的答案是“这取决于情况。”

关于javascript - setTimeout(fn, 0) 和 setTimeout(fn, 1) 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8341803/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com