The Symbol.species static accessor property

The @@species static accessor property is optionally added to a child constructor in order to notify the methods of the parent constructor about what the constructor should use if the parent constructor's methods are returning new instances. If the @@species static accessor property is not defined on a child constructor, then the methods of the parent constructor can use the default constructor.

Consider this example to understand the use of @@species—the map() method of the array objects returns a new Array instance. If we call the map() method of an object that inherits an Array object, then the map() method returns a new instance of the child constructor instead of the Array constructor, which ...

Get Learn ECMAScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.