Extract a list of values from an array of objects to an array based on a key in JavaScript.

2 min readMay 17, 2022

There may be a situation where you want to extract the list of values of a specific key from objects to an array.

Method 1:

In one way, we can use both the for loop and Array.push() method and achieve it.

For example, we have an array of objects as below

we can extract the values as shown below

Method 2:

The simple and easy way is using the map function as shown below

Here we’ve to assign the map function to a variable. If we don’t assign to a variable, then the whole array object will be printed as it is.

Hope this helps 😀🫠

Originally published at