Set[Symbol.species]

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2016.

The Set[Symbol.species] static accessor property is an unused accessor property specifying how to copy Set objects.

Syntax

js
Set[Symbol.species]

Return value

The value of the constructor (this) on which get [Symbol.species] was called. The return value is used to construct copied Set instances.

Description

The [Symbol.species] accessor property returns the default constructor for Set objects. Subclass constructors may override it to change the constructor assignment.

Note: This property is currently unused by all Set methods.

Examples

Species in ordinary objects

The [Symbol.species] property returns the default constructor function, which is the Set constructor for Set.

js
Set[Symbol.species]; // function Set()

Species in derived objects

In an instance of a custom Set subclass, such as MySet, the MySet species is the MySet constructor. However, you might want to overwrite this, in order to return parent Set objects in your derived class methods:

js
class MySet extends Set {
  // Overwrite MySet species to the parent Set constructor
  static get [Symbol.species]() {
    return Set;
  }
}

Specifications

Specification
ECMAScript® 2027 Language Specification
# sec-get-set-%symbol.species%

Browser compatibility

desktop mobile server
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Bun
Deno
Node.js
[Symbol.species]
Chrome – Full support
Chrome 51 (Release date: 2016-05-25)
footnote Full support
Edge – Full support
Edge 13 (Release date: 2015-11-12)
footnote Full support
Firefox – Full support
Firefox 41 (Release date: 2015-09-22)
footnote Full support
Opera – Full support
Opera 38 (Release date: 2016-06-08)
footnote Full support
Safari – Full support
Safari 10 (Release date: 2016-09-20)
footnote Full support
Chrome Android – Full support
Chrome Android 51 (Release date: 2016-06-08)
footnote Full support
Firefox for Android – Full support
Firefox for Android 41 (Release date: 2015-09-22)
footnote Full support
Opera Android – Full support
Opera Android 41 (Release date: 2016-10-25)
footnote Full support
Safari on iOS – Full support
Safari on iOS 10 (Release date: 2016-09-13)
footnote Full support
Samsung Internet – Full support
Samsung Internet 5 (Release date: 2016-12-15)
footnote Full support
WebView Android – Full support
WebView Android 51 (Release date: 2016-06-08)
footnote Full support
WebView on iOS – Full support
WebView on iOS 10 (Release date: 2016-09-13)
footnote Full support
Bun – Full support
Bun 1 (Release date: 2023-09-08)
footnote Full support
Deno – Full support
Deno 1 (Release date: 2020-05-13)
footnote Full support
Node.js – Full support
Node.js 6.5 (Release date: 2016-08-26)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also