I have the following variable:
> let location = {0: {1: {name: 'Fred', age: 20}, 5: {name: 'Ema', age: 55}}, 9: {3: {name: 'John', age: 29}}};
And I want to get the items in it:
> console.log(get_items(location));
[{name: 'Fred', age: 20}, {name: 'Ema', age: 55}, {name: 'John', age: 29}]
I've written the following function:
function get_items(location) {
return _.values(location).reduce((items, item)=> items.concat(_.values(item)), []);
}
But I wonder if there is a more elegant solution for this problem.