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


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

【Schedules repeated execution of callback every delay milliseconds.】

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

【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.】

如果 callback 不是一个函数,将会抛出 TypeError

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

这种方法有一个适用于 Promise 的自定义变体,可以通过 timersPromises.setInterval() 使用。

【This method has a custom variant for promises that is available using timersPromises.setInterval().】