Set.prototype.clear()
O método clear()
remove todos os elementos de um objeto Set
.
Sintaxe
mySet.clear();
Exemplos
Usando o método clear
js
var mySet = new Set();
mySet.add(1);
mySet.add("foo");
mySet.size; // 2
mySet.has("foo"); // true
mySet.clear();
mySet.size; // 0
mySet.has("bar"); // false
Especificações
Especificações | Status | Comentário |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Set.prototype.clear' in that specification. |
Padrão | Definições iniciais |
ECMAScript (ECMA-262) The definition of 'Set.prototype.clear' in that specification. |
Padrão em tempo real |
Compatibilidade com navegadores
BCD tables only load in the browser