Map.prototype.clear()
La méthode clear()
supprime tous les éléments d'un objet Map
.
Exemple interactif
Syntaxe
js
maMap.clear();
Valeur de retour
Exemple
Utiliser la méthode clear()
js
var maMap = new Map();
maMap.set("truc", "bidule");
maMap.set(1, "toto");
maMap.size; // 2
maMap.has("truc"); // true
maMap.clear();
maMap.size; // 0
maMap.has("truc"); // false
Spécifications
Specification |
---|
ECMAScript Language Specification # sec-map.prototype.clear |
Compatibilité des navigateurs
BCD tables only load in the browser