取消定时器


setImmediate()setInterval()setTimeout() 方法会各自返回表示安排的定时器的对象。 它们可用于取消定时器并阻止其触发。

使用 setImmediate()setTimeout() 的 promise 化的变体创建的定时器则无法取消。

The setImmediate(), setInterval(), and setTimeout() methods each return objects that represent the scheduled timers. These can be used to cancel the timer and prevent it from triggering.

It is not possible to cancel timers that were created using the promisified variants of setImmediate(), setTimeout().