has() 方法根据 WeakSet 是否存在相应对象返回布尔值。
ws.has(value);
WeakSet 中是否存在该对象。WeakSet 对象中存在指定的元素,返回 true;否则返回 false。has 方法var ws = new WeakSet();
var obj = {};
ws.add(window);
mySet.has(window); // 返回 true
mySet.has(obj); // 返回 false
| Specification | Status | Comment |
|---|---|---|
| ECMAScript 2015 (6th Edition, ECMA-262) WeakSet.prototype.has |
Standard | Initial definition. |
| ECMAScript Latest Draft (ECMA-262) WeakSet.prototype.has |
Draft |
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic support | 36 | 34 (34) | 未实现 | 23 | 未实现 |
| Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|
| Basic support | 未实现 | 34.0 (34) | 未实现 | 未实现 | 未实现 |