--- title: Set.prototype.clear() slug: Web/JavaScript/Reference/Global_Objects/Set/clear tags: - ECMAScript 2015 - JavaScript - Method - Prototype - Reference - set translation_of: Web/JavaScript/Reference/Global_Objects/Set/clear ---
clear()
메서드는 Set
객체를 비웁니다.
mySet.clear();
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")}}