The Set
.prototype
property represents the prototype for the Set
constructor.
Property attributes of Set.prototype
| |
---|---|
Writable | no |
Enumerable | no |
Configurable | no |
Set
instances inherit from Set.prototype
. You can use the constructor's prototype object to add properties or methods to all Set
instances.
Set.prototype.constructor
Set
function by default.Set.prototype.size
Set
object.Set.prototype.add(value)
Set
object. Returns the Set
object.Set.prototype.clear()
Set
object.Set.prototype.delete(value)
value
and returns the value that Set.prototype.has(value)
would have previously returned. Set.prototype.has(value)
will return false
afterwards.Set.prototype.entries()
Iterator
object that contains[value, value]
for each element in the Set
object, in insertion order. This is kept similar to the Map
object, so that each entry has the same value for its key and value here.Set.prototype.forEach(callbackFn[, thisArg])
callbackFn
once for each value present in the Set
object, in insertion order. If a thisArg
parameter is provided to forEach
, it will be used as the this
value for each callback.Set.prototype.has(value)
Set
object or not.Set.prototype.keys()
values()
function and returns a new Iterator
object that contains the values for each element in the Set
object in insertion order.Set.prototype.values()
Iterator
object that contains the values for each element in the Set
object in insertion order.Set.prototype[@@iterator]()
Iterator
object that contains the values for each element in the Set
object in insertion order.Specification | Status | Comment |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Set.prototype' in that specification. | Standard | Initial definition. |
ECMAScript Latest Draft (ECMA-262) The definition of 'Set.prototype' in that specification. | Draft |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | 38 | 12 | 13 | 11 | 25 | 8 |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | 38 | 38 | 12 | 14 | 25 | 8 | Yes |
Server | |
---|---|
Node.js | |
Basic support | Yes |
© 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/Set/prototype