Array[@@species]
accessor property returns the
Array
构造函数。
Array[Symbol.species]
Array
构造函数。
species
accessor property returns the default constructor for
Array
objects. Subclass constructors may override it to change the constructor assignment.
species
property returns the default constructor function, which is the
Array
constructor for
Array
对象:
Array[Symbol.species]; // function Array()
In a derived collection object (e.g. your custom array
MyArray
), the
MyArray
species is the
MyArray
constructor. However, you might want to overwrite this, in order to return parent
Array
objects in your derived class methods:
class MyArray extends Array {
// Overwrite MyArray species to the parent Array constructor
static get [Symbol.species]() { return Array; }
}
| 规范 |
|---|
|
ECMAScript (ECMA-262)
The definition of 'get Array [ @@species ]' in that specification. |
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@species
|
Chrome 51 | Edge 79 | Firefox 48 | IE No | Opera 38 | Safari 10 | WebView Android 51 | Chrome Android 51 | Firefox Android 48 | Opera Android 41 | Safari iOS 10 | Samsung Internet Android 5.0 |
nodejs
6.5.0
|
完整支持
不支持
用户必须明确启用此特征。
Array
Array.from()
Array.isArray()
Array.of()
Array.prototype.concat()
Array.prototype.copyWithin()
Array.prototype.entries()
Array.prototype.every()
Array.prototype.fill()
Array.prototype.filter()
Array.prototype.find()
Array.prototype.findIndex()
Array.prototype.flat()
Array.prototype.flatMap()
Array.prototype.forEach()
Array.prototype.includes()
Array.prototype.indexOf()
Array.prototype.join()
Array.prototype.keys()
Array.prototype.lastIndexOf()
Array.prototype.map()
Array.prototype.pop()
Array.prototype.push()
Array.prototype.reduce()
Array.prototype.reduceRight()
Array.prototype.reverse()
Array.prototype.shift()
Array.prototype.slice()
Array.prototype.some()
Array.prototype.sort()
Array.prototype.splice()
Array.prototype.toLocaleString()
Array.prototype.toSource()
Array.prototype.toString()
Array.prototype.unshift()
Array.prototype.values()
Array.prototype[@@iterator]()
get Array[@@species]
Function
Object
Object.prototype.__defineGetter__()
Object.prototype.__defineSetter__()
Object.prototype.__lookupGetter__()
Object.prototype.__lookupSetter__()
Object.prototype.hasOwnProperty()
Object.prototype.isPrototypeOf()
Object.prototype.propertyIsEnumerable()
Object.prototype.toLocaleString()
Object.prototype.toSource()
Object.prototype.toString()
Object.prototype.valueOf()
Object.setPrototypeOf()