Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

get Array[@@species]

这篇文章需要文法复核。如何帮忙。

这篇翻译不完整。请帮忙从英语翻译这篇文章

The Array[@@species] accessor property returns the Array constructor.

语法

Array[Symbol.species]

描述

The species accessor property returns the default constructor for Array objects. Subclass constructors may over-ride it to change the constructor assignment.

示例

The species property returns the default constructor function, which is the Array constructor for Array objects:

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; }
}

规范

Specification Status Comment
ECMAScript 2015 (6th Edition, ECMA-262)
get Array [ @@species ]
Standard Initial definition.
ECMAScript 2017 Draft (ECMA-262)
get Array [ @@species ]
Draft  

浏览器兼容性

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support ? 48 (48) ? ? ?
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? ? 48.0 (48) ? ? ?

参考

文档标签和贡献者

 此页面的贡献者: looch5
 最后编辑者: looch5,