The WeakMap object is a collection of key/value pairs in which the keys are weakly referenced. The keys must be objects and the values can be arbitrary values.

You can learn more about WeakMaps in the section WeakMap object in Keyed collections.

Documentation WeakMap by Mozilla Contributors, licensed under CC-BY-SA 2.5.

Static variables

staticfinalread onlylength:Int

The value of the length property is 0.

Constructor

new(?iterable:Any)

If an iterable object is passed, all of its elements will be added to the new WeakSet. null is treated as undefined.

Methods

delete(key:{}):Bool

Removes any value associated to the key. has(key) will return false afterwards.

get(key:{}):T

Returns the value associated to the key, or undefined if there is none.

has(key:{}):Bool

Returns a Boolean asserting whether a value has been associated to the key in the WeakMap object or not.

set(key:{}, value:T):WeakMap<T>

Sets the value for the key in the WeakMap object. Returns the WeakMap object.