刚遇到这个.它并没有真正影响任何东西,但我想知道为什么会发生.
如果我在带firebug的firefox中运行以下代码:
setInterval(function(param)
{
console.log("param is %o",param)
},500);
参数似乎被分配了一个模糊的随机值:
param is -2
param is -1
param is -2
param is 1
param is -1
param is 6
param is -1
param is 0
param is -2
param is 2
param is 0
param is 2
param is 0
param is 0
param is 0
[..]
param is 0
param is 0
param is 0
param is 0
param is 0
param is 0
param is 0
param is 911
param is 0
param is 0
param is 0
param is -1
我确实感谢我没有将任何参数传递给setInterval来传递给函数,但是javascript为什么选择传递此随机数?
我本来期望undefined或类似的东西…
干杯
ps.尚未在其他浏览器中进行过测试
解决方法:
它似乎取决于Firefox的CPU使用率.
我猜这是从应该调用回调开始的延迟.
编辑:I was right.这是回调调用被延迟的毫秒数.