NodeJS How To Have Unique Array of Objects

I want to have unique array of objects. So if I add an object, any objects which have same values won’t be added twice.
So I try use Set() data structure.

Adding Object directly to Set()

Output

Conclusion:

As you can see, the Set result is 3. It should be 2. So it doesn’t work

Adding a stringify Object to Set()

Output:

Conclusion:

The Set size is 2 with no duplicate values.

Overall Conclusion

So you can use Set but first stringifiy the objects than convert back the string to object by using JSON.parse() function

You can try thecoding yourself here:
Typescript Playground