TypedArray[@@species]
accessor property returns the constructor of a
typed array
.
species
accessor property returns the default constructor for
typed array
objects. Subclass constructors may over-ride it to change the constructor assignment.
species
property returns the default constructor function, which is one of the typed array constructors for a given
typed array
对象:
Int8Array[Symbol.species]; // function Int8Array() Uint8Array[Symbol.species]; // function Uint8Array() Float32Array[Symbol.species]; // function Float32Array()
In a derived collection object (e.g. your custom typed array
MyTypedArray
), the
MyTypedArray
species is the
MyTypedArray
constructor. However, you might want to overwrite this, in order to return a parent
typed array
object in your derived class methods:
class MyTypedArray extends Uint8Array {
// Overwrite MyTypedArray species to the parent Uint8Array constructor
static get [Symbol.species]() { return Uint8Array; }
}
| 规范 |
|---|
|
ECMAScript (ECMA-262)
The definition of 'get %TypedArray% [ @@species ]' in that specification. |
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@species
|
Chrome 51 | Edge 13 | Firefox 48 | IE No | Opera 38 | Safari No | WebView Android 51 | Chrome Android 51 | Firefox Android 48 | Opera Android 41 | Safari iOS No | Samsung Internet Android 5.0 |
nodejs
6.5.0
|
完整支持
不支持
用户必须明确启用此特征。
TypedArray
TypedArray.from()
TypedArray.of()
TypedArray.prototype.copyWithin()
TypedArray.prototype.entries()
TypedArray.prototype.every()
TypedArray.prototype.fill()
TypedArray.prototype.filter()
TypedArray.prototype.find()
TypedArray.prototype.findIndex()
TypedArray.prototype.forEach()
TypedArray.prototype.includes()
TypedArray.prototype.indexOf()
TypedArray.prototype.join()
TypedArray.prototype.keys()
TypedArray.prototype.lastIndexOf()
TypedArray.prototype.map()
TypedArray.prototype.reduce()
TypedArray.prototype.reduceRight()
TypedArray.prototype.reverse()
TypedArray.prototype.set()
TypedArray.prototype.slice()
TypedArray.prototype.some()
TypedArray.prototype.sort()
TypedArray.prototype.subarray()
TypedArray.prototype.toLocaleString()
TypedArray.prototype.toString()
TypedArray.prototype.values()
TypedArray.prototype[@@iterator]()
Int8Array
Uint8Array
Uint8ClampedArray
Int16Array
Uint16Array
Int32Array
Uint32Array
Float32Array
Float64Array
BigInt64Array
BigUint64Array
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()