Skip to content
Advertisement

Tag: unique

How to build a Set of unique Arrays?

I want to add many arrays to a Javascript set, and ensure that only unique arrays are added to the set. However, when I try adding the same array multiple times, it is always added instead of rejected. The .has() method always returns false as well. How do I fix this? Answer I’d use a Map instead, indexed by the

Javascript array sort and unique

I have a JavaScript array like this: I need the array elements to be unique and sorted: Even though the members of array look like integers, they’re not integers, since I have already converted each to be string: Is there any way to do all of these tasks in JavaScript? Answer This is actually very simple. It is much easier

Advertisement