Set.prototype

This is a new technology, part of the ECMAScript 2015 (ES6) standard .
This technology's specification has been finalized, but check the compatibility table for usage and implementation status in various browsers.

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

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

Description

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

Properties

Set.prototype.constructor
Returns the function that created an instance's prototype. This is the Set function by default.
Set.prototype.size
Returns the number of values in the Set object.

Methods

Set.prototype.add(value)
Appends a new element with the given value to the Set object. Returns the Set object.
Set.prototype.clear()
Removes all elements from the Set object.
Set.prototype.delete(value)
Removes the element associated to the 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()
Returns a new Iterator object that contains an array of [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])
Calls 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)
Returns a boolean asserting whether an element is present with the given value in the Set object or not.
Set.prototype.keys()
Is the same function as the 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()
Returns a new Iterator object that contains the values for each element in the Set object in insertion order.
Set.prototype[@@iterator]()
Returns a new Iterator object that contains the values for each element in the Set object in insertion order.

Specifications

Specification Status Comment
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'Set.prototype' in that specification.
Standard Initial definition.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 38 13 (13) 11 25 7.1
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support Not supported 38 13.0 (13) Not supported Not supported

8

See also

Document Tags and Contributors

Contributors to this page: fscholz, BlindWanderer, arai, realityking, jmdyck, spacetime29
Last updated by: fscholz,