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"]
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"]
Object.values(input).map(it => it.country)
You could map the objects to their countries.