I have an array of objects where each object has a an id key. some of those objects have re-occuring id's and I want to remove those re-occuring objects.
So for instance:
let array = [{
"id": "123",
"country": "Brazil",
"address": "xyz abc",
"date": "Dec 17, 1995, 9:45:17 PM"
},
{
"id": "443",
"country": "Russia",
"address": "qwd qwd qwdqw",
"date": "Dec 17, 1965, 9:45:17 PM"
},
{
"id": "123",
"country": "Canada",
"address": "ktktkt",
"date": "Dec 17, 1925, 9:45:17 PM"
},
.
.
.
{}]
in the array above since index 0 and index 2 share the same id key value, I would like to completely remove them both from the array.
- I am looking for optimal code in terms of complexity, only linear (O(n)).