aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/weakmap/clear
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/weakmap/clear')
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/weakmap/clear/index.html104
1 files changed, 104 insertions, 0 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/weakmap/clear/index.html b/files/zh-cn/web/javascript/reference/global_objects/weakmap/clear/index.html
new file mode 100644
index 0000000000..b2d51c64a1
--- /dev/null
+++ b/files/zh-cn/web/javascript/reference/global_objects/weakmap/clear/index.html
@@ -0,0 +1,104 @@
+---
+title: WeakMap.prototype.clear()
+slug: Web/JavaScript/Reference/Global_Objects/WeakMap/clear
+tags:
+ - JavaScript
+ - Method
+ - WeakMap
+ - clear()
+translation_of: Web/JavaScript/Reference/Global_Objects/WeakMap/clear
+---
+<div>{{JSRef}} {{obsolete_header}}</div>
+
+<p><code><strong>clear()</strong></code>用来从 <code>WeakMap对象中移除所有元素。</code>但不再是ECMAScript和它的实现部分。</p>
+
+<div class="warning">
+<p>Warning:</p>
+
+<p><img alt="WeakMap(no clear() any more).png" src="https://mdn.mozillademos.org/files/15608/WeakMap(no%20clear()%20any%20more).png" style="height: 490px; width: 735px;"></p>
+</div>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox"><em>wm</em>.clear();</pre>
+
+<h2 id="示例">示例</h2>
+
+<h3 id="使用_clear_方法">使用 <code>clear</code> 方法</h3>
+
+<pre class="brush: js;highlight:[10] example-bad">var wm = new WeakMap();
+var obj = {};
+
+wm.set(obj, "foo");
+wm.set(window, "bar");
+
+wm.has(obj); // true
+wm.has(window); // true
+
+wm.clear();
+
+wm.has(obj) // false
+wm.has(window) // false
+</pre>
+
+<h2 id="规范">规范</h2>
+
+<p>当前版本或者起草中没有这个方法,这个方法在版本 28(2014 年 10 月 14) 之前是 ECMAScript 6 起草规范的一部分,但是在起草之后的版本中被移除了。它不在是最终标准的一部分了 。</p>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p>{{CompatibilityTable}}</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>36</td>
+ <td>{{CompatNo}} [1]</td>
+ <td>11</td>
+ <td>23</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>Firefox Mobile (Gecko)</th>
+ <th>IE Mobile</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatNo}} [1]</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatNo}}</td>
+ <td>8</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<p>[1] The <code>clear()</code> 曾经在高于 20 版本低于 45 版本之间被支持。</p>
+
+<h2 id="相近">相近</h2>
+
+<ul>
+ <li>{{jsxref("WeakMap")}}</li>
+</ul>