Set
suggest changeIntroduction
The Set object stores unique values of any type, including primitives and object references.
Values are iterated in insertion order. A value can occur only once, as determined by the SameValueZero comparison algorithm.
ECMAScript specification for Set
Syntax
- new Set([iterable])
- mySet.add(value)
- mySet.clear()
- mySet.delete(value)
- mySet.entries()
- mySet.forEach(callback[, thisArg])
- mySet.has(value)
- mySet.values()
Parameters
| Parameter | Details |
|---|---|
| iterable | If an iterable object is passed, all of its elements will be added to the new Set. null is treated as undefined. |
| value | The value of the element to add to the Set object. |
| callback | Function to execute for each element. |
| thisArg | Optional. Value to use as this when executing callback. |
Remarks
SameValueZero mostly behaves like strict equality. Its notable differences are that NaN equals itself and +0 equals -0. Objects are still compared by identity, so two separate objects with the same properties are distinct set values. A Set may also contain undefined.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents