remove duplicate in aaray of objects
const addresses = [...]; // Some array I got from async call const uniqueAddresses = Array.from(new Set(addresses.map(a => a.id))) .map(id => { return addresses.find(a => a.id === id) })
Here is what the above code is Doing:
1. Create a Set from the addresses array.
2. Map the Set to an array of unique addresses.
3. Return the array of unique addresses.