--- title: Set.prototype.clear() slug: Web/JavaScript/Referencia/Objetos_globales/Set/clear tags: - ECMAScript6 - JavaScript - Prototype - set translation_of: Web/JavaScript/Reference/Global_Objects/Set/clear ---
El método clear()
remueve todos los elementos de un objeto Set
.
mySet.clear();
{{jsxref("undefined")}}.
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
Especificación | Estado | Comentario |
---|---|---|
{{SpecName('ES6', '#sec-set.prototype.clear', 'Set.prototype.clear')}} | {{Spec2('ES6')}} | Initial definition. |
{{SpecName('ESDraft', '#sec-set.prototype.clear', 'Set.prototype.clear')}} | {{Spec2('ESDraft')}} |
{{CompatibilityTable}}
Característica | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Soporte básico | 38 | {{CompatGeckoDesktop("19.0")}} | 11 | 25 | 7.1 |
Característica | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Soporte básico | {{CompatNo}} | 25 | {{CompatGeckoMobile("19.0")}} | {{CompatNo}} | {{CompatNo}} | 8 |