I have seen many implementations where people try to remove duplicate items from a javascript array by either looping over the entire array multiple times and searching for indices and checking wether other objects share that index. This seems like a very tedious approach.
I'd rather create a set (I do not care about the order) from the array and convert it back into an array. This approach however does not seem to work for objects. E.g. this fiddle prints the array exactly as it was before. How could I now convert the array from the example in the fiddle EFFICIENTLY to an array filtered on the 'key' variable? (Or any other combination of variables).
const array = [{
key: 'x',
value: 0
},
{
key: 'x',
value: 0
}
]
console.log(array);
const filtered = Array.from(new Set(array));
console.log(filtered)