Set.@@species
该Set[@@species]访问属性返回Set构造函数。
句法
Set[Symbol.species]描述
访问器属性返回Set对象的默认构造函数。子类的构造函数可能会重载它来改变构造函数的分配。
例子
该物种属性返回默认的构造函数,这是Set用于构造Set对象:
Set[Symbol.species]; // function Set()在一个派生的集合对象(例如你的自定义集合MySet)中,MySet物种是MySet构造函数。不过,你可能想要覆盖这个,为了返回Set派生类方法中的父对象:
class MySet extends Set {
// Overwrite MySet species to the parent Set constructor
static get [Symbol.species]() { return Set; }
}规范
Specification | Status | Comment |
|---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262)The definition of 'get Set @@species ' in that specification. | Standard | Initial definition. |
ECMAScript Latest Draft (ECMA-262)The definition of 'get Set @@species ' in that specification. | Living Standard | |
浏览器兼容性
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
Basic support | No support | 41 (41) | No support | No support | No support |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
Basic support | No support | No support | 41.0 (41) | No support | No support | No support |
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com

