Class WeakSet
The WeakSet is set whose elements are subject to garbage collection if there are no more references to the elements.
Only objects (no primitives) can be stored. Elements can’t be iterated.
API Version:
Available from version 21.2.
Constructor Summary
Constructor Description WeakSet ()Creates an empty Set. WeakSet (Iterable )If the passed value is null or undefined then an empty set is constructed.
Method Summary
Method Description add (Object )Adds an element to the set. delete (Object )Removes the element from the set. has (Object )Returns if this set contains the given object.
Methods inherited from class Object
assign , create , create , defineProperties , defineProperty , entries , freeze , fromEntries , getOwnPropertyDescriptor , getOwnPropertyNames , getOwnPropertySymbols , getPrototypeOf , hasOwnProperty , is , isExtensible , isFrozen , isPrototypeOf , isSealed , keys , preventExtensions , propertyIsEnumerable , seal , setPrototypeOf , toLocaleString , toString , valueOf , values
Constructor Details
WeakSet()
WeakSet()
Creates an empty Set.
WeakSet(Iterable)
WeakSet(values: Iterable )
If the passed value is null or undefined then an empty set is constructed. Else an iterable object is expected
that delivers the initial set entries.
Parameters:
values - The initial set entries.
Method Details
add(Object)
add(object: Object ): WeakSet
Adds an element to the set. Does nothing if the set already contains the element.
Parameters:
object - The object to add.
Returns:
delete(Object)
delete(object: Object ): Boolean
Removes the element from the set.
Parameters:
object - The object to be removed.
Returns:
true if the set contained the object that was removed. Else false is returned.
has(Object)
has(object: Object ): Boolean
Returns if this set contains the given object.
Parameters:
object - The object to look for.
Returns:
true if the set contains the object else false is returned.