I need to remove all duplicate objects from my array. I know I can do it by using filter or reduce, but I want to use set instead since (if it works) it should be the shortes and cleanest option.
origionalArray
[{type: "A", label: "A", department: "C"},
{type: "B", label: "B", department: "C"},
{type: "B", label: "B", department: "C"}]
Expected output:
[{type: "A", label: "A", department: "C"},
{type: "B", label: "B", department: "C"}]
I tried:
distinctArray = new Set(origionalArray);
But it returns origionalArray. So my guess is it compares the objects by reference. In java i would override the equals method. But as far as I can find it online this can't be done in TS.
Any ideas how I can get this done? Thank you for your help and time.