function formCategoryTrees(object) {
_.each(object,function(objectValues){
var leafCategoryId = objectValues["id"];
var leafCategoryName = objectValues["name"];
console.log(leafCategoryName+""+leafCategoryId );
if (objectValues.hasOwnProperty("children")) {
if (typeof objectValues["children"] == 'object')
console.log("In");
formCategoryTrees(objectValues["children"]);
}else{
console.log(leafCategoryName);
}
})
}
So i want to display the category tree as follows: Mobile & Accessories -> Mobiles
Mobile & Accessories -> Chargers
My JS Fiddle: http://jsfiddle.net/tfa8n5tj/