mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-13 10:44:03 +08:00
105 lines
3.7 KiB
HTML
105 lines
3.7 KiB
HTML
<article id="wikiArticle">
|
||
<div></div>
|
||
<p><code><strong>clear()</strong></code> 方法用来清空一个 <code>Set</code> 对象中的所有元素。</p>
|
||
<h2 id="Syntax" name="Syntax">语法</h2>
|
||
<pre class="syntaxbox"><code><em>mySet</em>.clear();</code>
|
||
</pre>
|
||
<h3 id="返回值">返回值</h3>
|
||
<p><a href="Reference/Global_Objects/undefined" title="undefined是全局对象的一个属性。也就是说,它是全局作用域的一个变量。undefined的最初值就是原始数据类型undefined。"><code>undefined</code></a>.</p>
|
||
<h2 id="Examples" name="Examples">示例</h2>
|
||
<pre class="brush: 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
|
||
</pre>
|
||
<h2 id="规范">规范</h2>
|
||
<table class="standard-table">
|
||
<tbody>
|
||
<tr>
|
||
<th scope="col">Specification</th>
|
||
<th scope="col">Status</th>
|
||
<th scope="col">Comment</th>
|
||
</tr>
|
||
<tr>
|
||
<td><a class="external" href="https://www.ecma-international.org/ecma-262/6.0/#sec-set.prototype.clear" hreflang="en" lang="en" rel="noopener">ECMAScript 2015 (6th Edition, ECMA-262)<br/><small lang="zh-CN">Set.prototype.clear</small></a></td>
|
||
<td><span class="spec-Standard">Standard</span></td>
|
||
<td>Initial definition.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><a class="external" href="https://tc39.github.io/ecma262/#sec-set.prototype.clear" hreflang="en" lang="en" rel="noopener">ECMAScript Latest Draft (ECMA-262)<br/><small lang="zh-CN">Set.prototype.clear</small></a></td>
|
||
<td><span class="spec-Draft">Draft</span></td>
|
||
<td> </td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<h2 id="浏览器兼容性">浏览器兼容性</h2>
|
||
<p></p><div class="blockIndicator warning"><strong><a class="external" href="https://github.com/mdn/browser-compat-data" rel="noopener">We're converting our compatibility data into a machine-readable JSON format</a></strong>.
|
||
This compatibility table still uses the old format,
|
||
because we haven't yet converted the data it contains.
|
||
<strong><a class="new" href="/zh-CN/docs/MDN/Contribute/Structures/Compatibility_tables" rel="nofollow">Find out how you can help!</a></strong></div>
|
||
<div class="htab">
|
||
<a id="AutoCompatibilityTable" name="AutoCompatibilityTable"></a>
|
||
<ul>
|
||
<li class="selected"><a>Desktop</a></li>
|
||
<li><a>Mobile</a></li>
|
||
</ul>
|
||
</div><p></p>
|
||
<div id="compat-desktop">
|
||
<table class="compat-table">
|
||
<tbody>
|
||
<tr>
|
||
<th>Feature</th>
|
||
<th>Chrome</th>
|
||
<th>Firefox (Gecko)</th>
|
||
<th>Internet Explorer</th>
|
||
<th>Opera</th>
|
||
<th>Safari</th>
|
||
</tr>
|
||
<tr>
|
||
<td>Basic support</td>
|
||
<td>38</td>
|
||
<td><a href="/en-US/Firefox/Releases/19" title="Released on 2013-02-19.">19.0</a> (19.0)</td>
|
||
<td>11</td>
|
||
<td>25</td>
|
||
<td>7.1</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<div id="compat-mobile">
|
||
<table class="compat-table">
|
||
<tbody>
|
||
<tr>
|
||
<th>Feature</th>
|
||
<th>Android</th>
|
||
<th>Chrome for Android</th>
|
||
<th>Firefox Mobile (Gecko)</th>
|
||
<th>IE Mobile</th>
|
||
<th>Opera Mobile</th>
|
||
<th>Safari Mobile</th>
|
||
</tr>
|
||
<tr>
|
||
<td>Basic support</td>
|
||
<td><span style="color: #f00;">未实现</span></td>
|
||
<td>25</td>
|
||
<td>19.0 (19.0)</td>
|
||
<td><span style="color: #f00;">未实现</span></td>
|
||
<td><span style="color: #f00;">未实现</span></td>
|
||
<td>8</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<h2 id="相关链接"><strong style="font-size: 2.14285714285714rem; font-weight: 700; letter-spacing: -1px; line-height: 30px;">相关链接</strong></h2>
|
||
<ul>
|
||
<li><a href="Reference/Global_Objects/Set" title="Set 对象允许你存储任何类型的唯一值,无论是原始值或者是对象引用。"><code>Set</code></a></li>
|
||
<li><a href="Reference/Global_Objects/Set/delete" title="delete() 方法可以从一个 Set 对象中删除指定的元素。"><code>Set.prototype.delete()</code></a></li>
|
||
</ul>
|
||
</article> |