I am trying to find the depth of a node and I am not able to understand the below code. "node" is a node object passed as input.
for (key in node)
{
if (node.hasOwnProperty(key))
{
child = node[key];
if (typeof child === 'object' && child !== null && key != 'parent')
{
This is what I have understood so far:
- Each node that is passed - we go through its properties
- For each property , the value of the property becomes a child
- if the type of child is an object and if the child is not equal to null and the property is not equal to the parent "node" that was passed. ( this part I dont understand)
Is my interpretation correct? Would appreciate any help. thanks!
Aucun commentaire:
Enregistrer un commentaire