I need a list of unique objects based on a specific key.
const array = [
{"name": "Joe", "age": 42},
{"name": "Donald", "age": 69},
{"name": "John", "age": 42},
]
How can i get a list of unique objects selected from the list assuming i want a list of people with unique ages.
const result = [
{"name": "Joe", "age": 42},
{"name": "Donald", "age": 69}
]
How can this be done in a performant way, is there a better way than iterating through the elements in a foreach and adding it if it does not exist in the resulting array?