0
我已经下面的代码片断:为什么JavaScript中的空数组输入循环?
console.log('**1**',parentNode.child.length); //1
for(var ch in parentNode.child)
{
console.log('PTree root child',parentNode.child[ch]); //2
}
在// 1个parentNode.child.length出来是0 但仍不言而喻内部的for循环,并给出下列管线// 2输出:
PTree root child (val) {
if (this.indexOf(val) === -1) {
this.push(val);
}
return this;
}
我不知道它为什么会发生。