Adding a value to a set
suggest changeTo add a value to a Set, use the .add() method:
mySet.add(5);
If the value already exists in the set, it is not added again, because sets contain unique values. Equality is SameValueZero, so NaN is treated as a duplicate of NaN.
Note that the .add() method returns the set itself, so you can chain add calls together:
mySet.add(1).add(2).add(3);
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents