[Solved] get all children names from object


You could write a simple recursive function that will traverse the contents of your tree:

var familyTree = {
    name: 'Alex',
    children: [
        {
            name: 'Ricky',
            children: [ ]
        },
        {
            name: 'John',
            children: [
                {
                    name: 'Tom',
                    children: [ ]
                }
            ]
        }
    ]
};

var traverse = function(tree) {
    console.log(tree.name);
    for (var i = 0; i < tree.children.length; i++) {
        traverse(tree.children[i]);    
    }
};

traverse(familyTree);

solved get all children names from object