Set
Last updated
Was this helpful?
Last updated
Was this helpful?
The Set object lets you store unique values of any type, whether primitive values or object references. For more information see: .
The size accessor property returns the number of elements in a Set object.
The set() method adds or updates an entry in a Set object with a specified key and a value.
void
The clear() method removes all elements from a Set object.
The delete() method removes the specified element from a Set object by key.
The entries() method returns a new iterator object that contains the [key, value] pairs for each element in the Set object in insertion order.
void
The forEach() method executes a provided function once for each value in the Set object, in insertion order.
The has() method returns a boolean indicating whether an element with the specified value exists in a Set object or not.
The keys() method returns a new iterator object that contains the keys for each element in the Set object in insertion order.
The values() method returns a new iterator object that contains the values for each element in the Set object in insertion order.
The size accessor property returns the number of elements in a Set object.
Sample
The set() method adds or updates an entry in a Set object with a specified key and a value.
Parameters
Sample
The clear() method removes all elements from a Set object.
Returns: void
Sample
The delete() method removes the specified element from a Set object by key.
Parameters
Sample
The entries() method returns a new iterator object that contains the [key, value] pairs for each element in the Set object in insertion order. In this particular case, this iterator object is also an iterable, so the for-of loop can be used..
Sample
The forEach() method executes a provided function once for each value in the Set object, in insertion order.
Parameters
Returns: void
Sample
The has() method returns a boolean indicating whether an element with the specified value exists in a Set object or not.
Parameters
Sample
The keys() method returns a new iterator object that contains the keys for each element in the Set object in insertion order. In this particular case, this iterator object is also an iterable, so a for...of loop can be used.
Sample
The values() method returns a new iterator object that contains the values for each element in the Set object in insertion order.
Sample
Type
value ;
Returns: the Set itself
value ;
Returns: True if the specified element was successfully removed from the Set; false otherwise.
Returns: the iterator that can be used in for of loops
callback ;
thisArgument ;
key ;
Returns: True if the Set contains an element with the specified key; false otherwise.
Returns: the iterator that can be used in for of loops
Returns: the iterator that can be used in for of loops