Computer >> Computer tutorials >  >> Programming >> Javascript

Name some methods of weakMap instances in javascript?


Following are some of the methods available on weakMap instances in javaScript −

1. WeakMap.prototype.delete(key)

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

2. WeakMap.prototype.get(key)

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

3. WeakMap.prototype.has(key)

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

4. WeakMap.prototype.set(key, value)

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