has()
メソッドは、特定の値をもつ要素が WeakSet
オブジェクト内に存在するかどうかを示す真偽値を返します。
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
構文
ws.has(value);
引数
value
WeakSet
オブジェクトに存在するかテストする値です。
返値
- Boolean
WeakSet
オブジェクト内に特定の値をもつ要素が存在していたらtrue
を返します。さもなければfalse
を返します。
例
has() メソッドの使用
var ws = new WeakSet();
var obj = {};
ws.add(window);
mySet.has(window); // returns true
mySet.has(obj); // returns false
仕様書
ブラウザーの互換性
BCD tables only load in the browser