是否重用了 JS setTimeout/setInterval return 值?

Are JS setTimeout/setInterval return values reused?

我知道 setTimeoutsetInterval 的 return 值在给定的 DOM 中是唯一的,至少对于当时的定时器 运行 ,但是一旦这些计时器之一完成或被取消,是否会重复使用相同的数字?例如 setTimeout 输出一个 setInterval 已经给出的数字,或者类似的?

我的直觉是我可以相信它们永远不会被重用。否则,我会觉得有必要在定时器结束或我取消它时立即清除指向定时器标识符的变量,以免其他代码稍后在指向不相关的定时器(偶然被分配)时试图取消它相同的标识符)。

假设它们不应该被重复使用,是否有任何行为不端的浏览器?

通过一连串的规范和调用,最终 setTimeout / setInterval 的 return 值 应该 来自“the list of active timers":

Each object that implements the WindowTimers interface has a list of active timers. Each entry in this lists is identified by a number, which must be unique within the list for the lifetime of the object that implements the WindowTimers interface.

正如该部分所指定的,该编号在 (object that...) window 对象的生命周期内是唯一的,该对象在翻页。

但是,关于实施和 "misbehaving browsers",我认为这不是真正可以回答的问题。