--- title: Set.prototype.clear() slug: Web/JavaScript/Reference/Global_Objects/Set/clear tags: - ECMAScript6 - JavaScript - Method - Prototype - set translation_of: Web/JavaScript/Reference/Global_Objects/Set/clear ---
Метод clear()
удаляет все элементы из объекта Set
.
mySet.clear();
{{jsxref("undefined")}}.
clear
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
Specification | Status | Comment |
---|---|---|
{{SpecName('ES2015', '#sec-set.prototype.clear', 'Set.prototype.clear')}} | {{Spec2('ES2015')}} | Initial definition. |
{{SpecName('ESDraft', '#sec-set.prototype.clear', 'Set.prototype.clear')}} | {{Spec2('ESDraft')}} |
{{Compat("javascript.builtins.Set.clear")}}