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

WeakMap.prototype

WeakMap.prototype属性表现为WeakMap的构造器。

| WeakMap.prototype属性的属性特性 |

|:----|

| Writable | no |

| Enumerable | no |

| Configurable | no |

描述

WeakMap实例从WeakMap.prototype继承了所有属性。你可以在WeakMap构造器中添加属性和方法,从而使得所有实例中都有效。

WeakMap.prototype本身只是一个普通的对象:

代码语言:javascript
复制
Object.prototype.toString.call(WeakMap.prototype); // "[object Object]"

属性

WeakMap.prototype.constructor返回创建WeakMap实例的原型函数。WeakMap函数是默认的。

方法

WeakMap.prototype.delete(key)移除key的关联对象。执行后WeakMap.prototype.has(key)返回false。WeakMap.prototype.get(key)返回key关联对象, 或者undefined(没有key关联对象时)。WeakMap.prototype.has(key)根据是否有key关联对象返回一个Boolean值。

WeakMap.prototype.set(key, value)在WeakMap中设置一组key关联对象,返回这个WeakMap对象。WeakMap.prototype.clear()WeakMap中移除所有的key/value 。 注意, 这是一个WeakMap类型对象需要的方法,难道不是吗? (参看WeakMap)

规范

Specification

Status

Comment

ECMAScript 2015 (6th Edition, ECMA-262)The definition of 'WeakMap.prototype' in that specification.

Standard

Initial definition.

ECMAScript Latest Draft (ECMA-262)The definition of 'WeakMap.prototype' in that specification.

Living Standard

浏览器兼容性

Feature

Chrome

Edge

Firefox (Gecko)

Internet Explorer

Opera

Safari

Basic support

36

(Yes)

6.0 (6.0)

11

23

7.1

Feature

Android

Chrome for Android

Edge

Firefox Mobile (Gecko)

IE Mobile

Opera Mobile

Safari Mobile

Basic support

No support

No support

(Yes)

6.0 (6.0)

No support

No support

8

扫码关注腾讯云开发者

领取腾讯云代金券