typescript object to array code example
Example 1: convert object object to array typescript
const persons = {
john: { age: 23, year:2010},
jack: { age: 22, year:2011},
jenny: { age: 21, year:2012}
}
const resultArray = Object.keys(persons).map(index => {
let person = persons[index];
return person;
});
Example 2: javascript object to array
fooArray = Object.entries(fooObj);
fooArray.forEach(([key, value]) => {
console.log(key);
console.log(value);
})
Example 3: typescript object to array
var resultArray = Object.keys(persons).map(function(personNamedIndex){
let person = persons[personNamedIndex];
return person;
});