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;
}
我不知道它爲什麼會發生。