W3cubDocs

/JavaScript

WeakSet.prototype

The WeakSet.prototype property represents the prototype for the WeakSet constructor.

Property attributes of WeakSet.prototype
Writable no
Enumerable no
Configurable no

Description

WeakSet instances inherit from WeakSet.prototype. You can use the constructor's prototype object to add properties or methods to all WeakSet instances.

WeakSet.prototype is itself just an ordinary object:

Object.prototype.toString.call(WeakSet.prototype); // "[object Object]"

Properties

WeakSet.prototype.constructor
Returns the function that created an instance's prototype. This is the WeakSet function by default.

Methods

WeakSet.prototype.add(value)
Appends a new object with the given value to the WeakSet object.
WeakSet.prototype.delete(value)
Removes the element associated to the value. WeakSet.prototype.has(value) will return false afterwards.
WeakSet.prototype.has(value)
Returns a boolean asserting whether an element is present with the given value in the WeakSet object or not.
WeakSet.prototype.clear()
Removes all elements from the WeakSet object.

Specifications

Browser compatibility

Feature Chrome Edge Firefox Internet Explorer Opera Safari
Basic support 36 Yes 34 No 23 9
Feature Android webview Chrome for Android Edge mobile Firefox for Android IE mobile Opera Android iOS Safari
Basic support 36 36 Yes 34 No 23 9

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/prototype