Was this page helpful?
HashSet¶
HashSet()
Represents a unique set of values.
Constructor¶
new HashSet()
Source
Methods¶
add(key) → {boolean}
Adds a new item to the set.
Parameters:
| Name | Type | Description |
|---|---|---|
key |
Object |
Source
Returns:
Returns true if it was added to the set; false if the key is already present.
- Type
- boolean
contains() → {boolean}
Source
Returns:
Returns true if the key is present in the set.
- Type
- boolean
remove(key) → {boolean}
Removes the item from set.
Parameters:
| Name | Type | Description |
|---|---|---|
key |
Source
Returns:
Returns true if the key existed and was removed, otherwise it returns false.
- Type
- boolean
toArray() → {Array}
Returns an array containing the set items.
Source
Returns:
- Type
- Array