setInterval(callback[, delay[, ...args]])

  • callback <Function> 当定时器到点时调用的函数。
  • delay <number> 调用 callback 之前等待的毫秒数。默认值: 1
  • ...args <any> 当调用 callback 时传入的可选参数。
  • 返回: <Timeout> 用于 clearInterval()

安排每隔 delay 毫秒重复执行 callback

delay 大于 2147483647 或小于 1 时,则 delay 将会被设置为 1。 非整数的 delay 会被截断为整数。

如果 callback 不是函数,则抛出 TypeError

  • callback <Function> The function to call when the timer elapses.
  • delay <number> The number of milliseconds to wait before calling the callback. Default: 1.
  • ...args <any> Optional arguments to pass when the callback is called.
  • Returns: <Timeout> for use with clearInterval()

Schedules repeated execution of callback every delay milliseconds.

When delay is larger than 2147483647 or less than 1, the delay will be set to 1. Non-integer delays are truncated to an integer.

If callback is not a function, a TypeError will be thrown.