1const persons = {
2 john: { age: 23, year:2010},
3 jack: { age: 22, year:2011},
4 jenny: { age: 21, year:2012}
5}
6const resultArray = Object.keys(persons).map(index => {
7 let person = persons[index];
8 return person;
9});
10
11
1//Supposing fooObj to be an object
2
3fooArray = Object.entries(fooObj);
4
5fooArray.forEach(([key, value]) => {
6 console.log(key); // 'one'
7 console.log(value); // 1
8})
9
1var resultArray = Object.keys(persons).map(function(personNamedIndex){
2 let person = persons[personNamedIndex];
3 // do something with person
4 return person;
5});
6
7// you have resultArray having iterated objects