From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../reference/global_objects/set/clear/index.html | 120 +++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 files/zh-cn/web/javascript/reference/global_objects/set/clear/index.html (limited to 'files/zh-cn/web/javascript/reference/global_objects/set/clear/index.html') diff --git a/files/zh-cn/web/javascript/reference/global_objects/set/clear/index.html b/files/zh-cn/web/javascript/reference/global_objects/set/clear/index.html new file mode 100644 index 0000000000..6103b63a67 --- /dev/null +++ b/files/zh-cn/web/javascript/reference/global_objects/set/clear/index.html @@ -0,0 +1,120 @@ +--- +title: Set.prototype.clear() +slug: Web/JavaScript/Reference/Global_Objects/Set/clear +tags: + - ECMAScript6 + - JavaScript + - Prototype + - set + - 原型 + - 方法 +translation_of: Web/JavaScript/Reference/Global_Objects/Set/clear +--- +
{{JSRef}}
+ +

clear() 方法用来清空一个 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
+
+ +

规范

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{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() }}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support38{{CompatGeckoDesktop("19.0")}}11257.1
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{ CompatNo() }}25{{CompatGeckoMobile("19.0")}}{{ CompatNo() }}{{ CompatNo() }}8
+
+ +

相关链接

+ + -- cgit v1.2.3-54-g00ecf