Node.js examples for Object:Object Operation
Get depth of object
function depthOf(object) { var level = 1;// w w w . ja v a 2 s. co m var key; for(key in object) { if (!object.hasOwnProperty(key)) continue; if(typeof object[key] == 'object'){ var depth = depthOf(object[key]) + 1; level = Math.max(depth, level); } } return level; }