convert object to array typescript 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: convert object to array javascript
var object = {'Apple':1,'Banana':8,'Pineapple':null};
var k = Object.keys(object);
var v = Object.values(object);
Example 3: typescript object to array
var resultArray = Object.keys(persons).map(function(personNamedIndex){
let person = persons[personNamedIndex];
return person;
});