Convert object to an array of objects?

You can use .map() with Object.keys():

let data = {
    "1": "Technology",
    "2": "Startup",
    "3": "IT",
};

let result = Object.keys(data)
                   .map(key => ({id: Number(key), name: data[key]}));

console.log(result);

Useful Resources:

Leave a Comment