Set.prototype.clear()
La méthode clear()
permet de retirer tous les éléments d'un ensemble Set
.
Exemple interactif
Syntaxe
monSet.clear();
Valeur de retour
Exemples
var monSet = new Set();
monSet.add(1);
monSet.add("toto");
monSet.size; // 2
monSet.has("toto"); // true
monSet.clear();
monSet.size; // 0
monSet.has("truc") // false
Spécifications
Specification |
---|
ECMAScript Language Specification # sec-set.prototype.clear |
Compatibilité des navigateurs
BCD tables only load in the browser