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 September 2015.
La méthode has()
renvoie un booléen indiquant si un objet donné est contenu dans l'ensemble WeakSet
.
Exemple interactif
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
Syntaxe
ws.has(valeur);
Paramètres
valeur
-
Ce paramètre est obligatoire. Il représente l'objet dont on souhaite savoir s'il est, ou non, présent dans l'objet
WeakSet
.
Valeur renvoyée
- Booléen
-
La méthode renvoie
true
si l'objetWeakSet
contient bien un élément avec la valeur donnée,false
sinon.
Exemples
var ws = new WeakSet();
var obj = {};
ws.add(window);
mySet.has(window); // renvoie true
mySet.has(obj); // renvoie false
Spécifications
Specification |
---|
ECMAScript® 2025 Language Specification # sec-weakset.prototype.has |
Compatibilité des navigateurs
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
has |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support