Answers for "convert object object to array typescript"

5

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;
});
Posted by: Guest on November-30-2020
0

typescript object to array

var resultArray = Object.keys(persons).map(function(personNamedIndex){
    let person = persons[personNamedIndex];
    // do something with person
    return person;
});

// you have resultArray having iterated objects
Posted by: Guest on August-11-2020

Code answers related to "convert object object to array typescript"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language