convert object array to string 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: typescript object to array
var resultArray = Object.keys(persons).map(function(personNamedIndex){
let person = persons[personNamedIndex];
return person;
});
Example 3: js array with objects to string
var array = new Array();
var string;
array[0] = {key: value};
array[1] = {key1: value1};
string = JSON.stringify(array);