WeakSet.prototype.has()

has() メソッドは、特定の値をもつ要素が WeakSet オブジェクト内に存在するかどうかを示す真偽値を返します。

試してみましょう

構文

ws.has(value);

引数

value

WeakSet オブジェクトに存在するかテストする値です。

返値

Boolean

WeakSet オブジェクト内に特定の値をもつ要素が存在していたら true を返します。さもなければ false を返します。

has() メソッドの使用

js
var ws = new WeakSet();
var obj = {};
ws.add(window);

mySet.has(window); // returns true
mySet.has(obj); // returns false

仕様書

Specification
ECMAScript Language Specification
# sec-weakset.prototype.has

ブラウザーの互換性

BCD tables only load in the browser

関連情報