Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 142100

Javascript: How to get a unique list of values assigned to the same property from an array of objects?

$
0
0

I'm trying to make a unique list of all the values assigned to the city property, which is buried in an object within an object, and I have an array of such objects

buildings = [ { name: 'Victoria Bell Tower', filterOptions: { city: 'Ottowa', state: 'Canada', buildingType: 'Parliament Building', }, }, { name: 'Cathedral', filterOptions: { city: 'Washington D.C.', state: '', buildingType: 'Cathedral', }, }, { name: 'Post Office', filterOptions: { city: 'Washington D.C.', state: '', buildingType: 'Post Office', }, }]

What's a practical way to get a unique array of the cities properties:

cities = ['Ottowa', 'Washington D.C.']


Viewing all articles
Browse latest Browse all 142100

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>