Skip to content
Advertisement

How to convert array of key–value objects to array of objects with a single property?

I have an array of objects like this:

JavaScript

I need to convert it to the following format:

JavaScript

How can this be done using JavaScript?

Advertisement

Answer

You can use .map

JavaScript

also if you use ES2015 you can do it like this

JavaScript

Example

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement