-1

I have a list of objects

{
    "Anne": { age: 3, country: "USA" },
    "Flex": { age: 5, country: "UK" }
}

How can I get an array of country? I can use Object.Values. How about in nested object in javascript?

["USA","UK"]
susu watari
  • 177
  • 1
  • 2
  • 11
  • Related: [From an array of objects, extract value of a property as array](https://stackoverflow.com/q/19590865/218196) – Felix Kling Mar 28 '19 at 19:19

1 Answers1

1
 Object.values(input).map(it => it.country)

You could map the objects to their countries.

Jonas Wilms
  • 132,000
  • 20
  • 149
  • 151