javascript - How to transform an object into an array of objects? -


i looking way transform object array of objects, , remove first unique key.

how can make this:

{f56hdhgf54: {name: 'sam', age: 34}, h65fg9f7d: {name: 'john', age: 42}} 

into this:

[{name: 'sam', age: 34}, {name: 'john', age: 42}] 

so can .map through this:

result.map((person) => {    console.log(person.name, person.age) }) 

you can use object.keys() array of keys , map() change keys values or in case objects.

var obj = {f56hdhgf54: {name: 'sam', age: 34}, h65fg9f7d: {name: 'john', age: 42}}    var result = object.keys(obj).map(function(e) {    return obj[e];  });    console.log(result);


Comments