Convert object values to new array

  • A+
Category:Languages

This is my object:

"names": [{         "first": "Linda"     },     {         "first": "Maverick"     }, ]; 

How can I convert this, so that I get an array with values:

["Linda", "Maverick"] 

 


Just use map:

data.names.map(name => name.first) 

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: