Map.prototype.has()
La méthode has()
renvoie un booléen permettant de déterminer si l'objet Map
en question contient la clé donnée.
Exemple interactif
Syntaxe
js
maMap.has(clé);
Paramètres
clé
-
Ce paramètre obligatoire correspond à la clé dont on veut savoir si elle appartient à l'objet
Map
.
Valeur de retour
Cette méthode renvoie un booléen : true
si un élément avec cette clé existe au sein de l'objet Map
et false
sinon.
Exemples
js
var maMap = new Map();
maMap.set("truc", "toto");
maMap.has("truc"); // renvoie true
maMap.has("machin"); // renvoie false
Spécifications
Specification |
---|
ECMAScript Language Specification # sec-map.prototype.has |
Compatibilité des navigateurs
BCD tables only load in the browser