Firefox setTimeout(func, ms) sending default parameters to callback

前端 未结 2 1370
别那么骄傲
别那么骄傲 2021-01-21 23:06

I am unable to find out more about this default parameter that I ran across and was hoping that someone could point out an explanation.

In Firefox (3.6 in this case) if

相关标签:
2条回答
  • 2021-01-21 23:25

    From MDC

    Gecko passes an extra parameter to the callback routine, indicating the "lateness" of the timeout in milliseconds.

    Because the "actual" delay maybe longer than the delay specified in the setTimeoutcall, the "lateness" will be zero if the function was called exactly after the delay specified, non-zero otherwise.

    0 讨论(0)
  • 2021-01-21 23:26

    You're correct that it's the offset. It'll usually be zero (meaning it was called when it should have been), but if the JS engine is backed up, it'll be higher, or it can even be negative.

    reference: https://developer.mozilla.org/en/DOM/window.setTimeout

    (see the part in yellow)

    0 讨论(0)
提交回复
热议问题