WeakMap.prototype属性表现为 WeakMap的构造器。
WeakMap.prototype 属性的属性特性: |
|
|---|---|
| writable | false |
| enumerable | false |
| configurable | false |
描述
WeakMap.prototype继承了所有属性。你可以在WeakMap构造器中添加属性和方法,从而使得所有实例中都有效。
WeakMap.prototype 本身只是一个普通的对象:
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中移除所有的key/value 。 注意,该方法已弃用,但可以通过创建一个空的WeakMap并替换原对象来实现 (参看WeakMap的后半部分)
规范
| Specification | Status | Comment |
|---|---|---|
| ECMAScript 2015 (6th Edition, ECMA-262) WeakMap.prototype |
Standard | Initial definition. |
| ECMAScript Latest Draft (ECMA-262) WeakMap.prototype |
Draft |
浏览器兼容
We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains.
Find out how you can help!
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic support | 36 | 6.0 (6.0) | 11 | 23 | 7.1 |
| Ordinary object | ? | 40 (40) | ? | ? | ? |
| Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
| Basic support | 未实现 | 未实现 | 6.0 (6.0) | 未实现 | 未实现 | 8 |
| Ordinary object | ? | ? | 40.0 (40) | ? | ? | ? |