--- title: WeakSet.prototype.has() slug: Web/JavaScript/Reference/Global_Objects/WeakSet/has translation_of: Web/JavaScript/Reference/Global_Objects/WeakSet/has ---
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 |
|---|---|---|
| {{SpecName('ES6', '#sec-weakset.prototype.has', 'WeakSet.prototype.has')}} | {{Spec2('ES6')}} | Initial definition. |
| {{SpecName('ESDraft', '#sec-weakset.prototype.has', 'WeakSet.prototype.has')}} | {{Spec2('ESDraft')}} |