I have following code snippet:
console.log('**1**',parentNode.child.length); //1
for(var ch in parentNode.child)
{
console.log('PTree root child',parentNode.child[ch]); //2
}
In //1 parentNode.child.length comes out to be 0 but still it goes inside the for loop and gives following output in line //2:
PTree root child (val) {
if (this.indexOf(val) === -1) {
this.push(val);
}
return this;
}
I am not sure why it is happening.