首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Set.@@species

Set[@@species]访问属性返回Set构造函数。

句法

代码语言:javascript
复制
Set[Symbol.species]

描述

访问器属性返回Set对象的默认构造函数。子类的构造函数可能会重载它来改变构造函数的分配。

例子

该物种属性返回默认的构造函数,这是Set用于构造Set对象:

代码语言:javascript
复制
Set[Symbol.species]; // function Set()

在一个派生的集合对象(例如你的自定义集合MySet)中,MySet物种是MySet构造函数。不过,你可能想要覆盖这个,为了返回Set派生类方法中的父对象:

代码语言:javascript
复制
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

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com