JavaScript Set Reference
The JavaScript Set Object
A Set is a collection of unique values.
Each value can only occur once in a Set.
The values can be of any type, primitive values or objects.
See Also:
JavaScript Set Methods and Properties
Method | Description |
---|---|
new Set() | Creates a new set |
add() | Adds a new element to a set |
clear() | Removes all elements from a set |
delete() | Removes an element from a set |
difference() | Returns the difference between two sets |
entries() | Returns an Iterator with the [value,value] pairs from a set |
forEach() | Invokes a callback for each element in a set |
has() | Returns true if a value exists |
intersection() | Returns the intersection of two sets |
isDisjointFrom() | Returns true if no elements in a set are elements in another set |
isSubsetOf() | Returns true if a set is a subset of another set |
isSupersetOf() | Returns true if a set is a superset of another set |
keys() | Same as values() |
symmetricDifference() | Returns the symmetric difference between two set |
union() | Returns the union of two sets |
values() | Returns an Iterator with the values in a set |
Sets have only one property:
Property | Description |
---|---|
size | Returns the number of elements in a Set |