JavaScript Set Reference
New to JavaScript Sets?
Complete Set Reference
Revised July 2025
| 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 |