我感到困惑的是,下面的路段在8号独立党中造成了无限的 lo。
for (var i in theArray) {
this.theArray.push(theArray[i]);
}
IE8陷入了我不理解的无限圈子,为什么因为<代码>了。 “Array是一个全球阵列,而“Array<>/code>是一个地方变量。
If I had something like the following I would understand that an infinite loop would occurs:
for (var i in theArray) {
theArray.push(theArray[i]);
}
This only happens in IE8. Does IE8 treat variables and scoping differently?
EDIT
这里,我是在物体内
this.theArray = new Array();
this.selection = function(theArray) {
for (var i in theArray) {
this.theArray.push(theArray[i]);
}
}
EDIT
我发现,我把全球变数作为理由。 Duh! 为什么在第八届国际能源论坛中不这样做?