Skip to main content
Version: 3.27.2

Symbol.species

The well-known symbol Symbol.species specifies a function-valued property that the constructor function uses to create derived objects.

Warning: The existence of Symbol.species allows execution of arbitrary code and may create security vulnerabilities. It also makes certain optimizations much harder. Engine implementers are investigating whether to remove this feature. Avoid relying on it if possible.

Value

The well-known symbol Symbol.species.

Description

The Symbol.species accessor property allows subclasses to override the default constructor for objects. This specifies a protocol about how instances should be copied. For example, when you use copying methods of arrays, such as Array.prototype.map(). the map() method uses instance.constructor[Symbol.species] to get the constructor for constructing the new array.

All built-in implementations of Symbol.species return the this value, which is the current instance's constructor. This allows copying methods to create instances of derived classes rather than the base class — for example, map() will return an array of the same type as the original array.