gpt4 book ai didi

javascript - setTimeout函数中未指定延迟是否意味着零延迟?

转载 作者:行者123 更新时间:2023-11-28 13:07:56 24 4
gpt4 key购买 nike

setTimeout函数中未指定延迟是否意味着零延迟?
也就是说,是这样的调用:

setTimeout(function() {
//do something
}); // NOTE: no delay specified

等于:

setTimeout(function() {
//do something
}, 0); // NOTE: zero delay specified

最佳答案

正如 setTimeout documentation 中提到的,delay 是一个可选值,如果未指定,则将设置为 0

delay Optional

The time, in milliseconds (thousandths of a second), the timer should wait before the specified function or code is executed. If this parameter is omitted, a value of 0 is used, meaning execute "immediately", or more accurately, as soon as possible. Note that in either case, the actual delay may be longer than intended; see Reasons for delays longer than specified below.

关于javascript - setTimeout函数中未指定延迟是否意味着零延迟?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45101905/

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