I am trying to make a object which could the number of parents of element .
I have a array of objects .in which there is two field **to** and **from** .I want to calculate the length of parents 
here is my code ?

Example 

* **"node\_from": 11,** don't have parent ..it don't have **to** field .so it length is **0**,zero;
* **"node\_from": 12,** is coming from 11 .so it have parent .so it parent length is one or 1 and same as in 13 , 14,16,18,19.
* **"node\_from": 15,** has 2 parent coming from 13 and 14 ..so it length is 2 .

can we find this 

here is my code

<https://jsfiddle.net/ood2ezvz/2/>

```
var obj={}
for(var i=0;i<node.length;i++){

console.log(node[i]);
var node=node[i]
if(obj.hasOwnProperty(node.node_from)){
obj[node_from]=obj[node_from]++;
}else{
obj[node_from]=0;
}

}
console.log(obj)

```

It is giving error ?

**Expected out put** `{ 11:0, 12:1, 13:1, 14:1, 15:2, 16:1, 17:1, 18:1 19:1 }`