WeakMap.prototype属性表现为 WeakMap的构造器。
WeakMap.prototype 属性的属性特性: |
|
|---|---|
| writable | false |
| enumerable | false |
| configurable | false |
WeakMap 实例从 WeakMap.prototype继承了所有属性。你可以在WeakMap构造器中添加属性和方法,从而使得所有实例中都有效。
WeakMap.prototype 本身只是一个普通的对象:
Object.prototype.toString.call(WeakMap.prototype); // "[object Object]"
WeakMap.prototype.constructorWeakMap函数是默认的。WeakMap.prototype.delete(key)WeakMap.prototype.has(key)返回false。WeakMap.prototype.get(key)key关联对象, 或者 undefined(没有key关联对象时)。WeakMap.prototype.has(key)WeakMap.prototype.set(key, value)WeakMap对象。WeakMap.prototype.clear() 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 |
| 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) | ? | ? | ? |