WeakSet.prototype.has()
Baseline
Widely available
This feature is well established and works across many devices and browser versions. Itâs been available across browsers since 2015å¹´9æ.
has() ã¡ã½ããã¯ãç¹å®ã®å¤ããã¤è¦ç´ ã WeakSet ãªãã¸ã§ã¯ãå
ã«åå¨ãããã©ããã示ãçå½å¤ãè¿ãã¾ãã
試ãã¦ã¿ã¾ããã
const weakset1 = new WeakSet();
const object1 = {};
const object2 = {};
weakset1.add(object1);
console.log(weakset1.has(object1));
// Expected output: true
console.log(weakset1.has(object2));
// Expected output: false
æ§æ
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® 2027 Language Specification> # sec-weakset.prototype.has> |