aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/weakmap/has/index.html
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/javascript/reference/global_objects/weakmap/has/index.html
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/weakmap/has/index.html')
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/weakmap/has/index.html123
1 files changed, 123 insertions, 0 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/weakmap/has/index.html b/files/zh-cn/web/javascript/reference/global_objects/weakmap/has/index.html
new file mode 100644
index 0000000000..2c411d429d
--- /dev/null
+++ b/files/zh-cn/web/javascript/reference/global_objects/weakmap/has/index.html
@@ -0,0 +1,123 @@
+---
+title: WeakMap.prototype.has()
+slug: Web/JavaScript/Reference/Global_Objects/WeakMap/has
+translation_of: Web/JavaScript/Reference/Global_Objects/WeakMap/has
+---
+<div>{{JSRef}}</div>
+
+<p> <code><strong>has()</strong></code> 方法根据WeakMap对象的元素中是否存在key键返回一个boolean值。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox"><code><em>wm</em>.has(key);</code></pre>
+
+<h3 id="Parameters">Parameters</h3>
+
+<dl>
+ <dt>key</dt>
+ <dd>必须的。用来检测WeakMap对象中是否存在元素的键为key。</dd>
+</dl>
+
+<h3 id="Return_value">Return value</h3>
+
+<dl>
+ <dt>Boolean</dt>
+ <dd>如果指定的key存在于某个元素中则返回true,否则返回flase。</dd>
+</dl>
+
+<h2 id="例子">例子</h2>
+
+<h3 id="使用_has方法">使用 <code>has方法</code></h3>
+
+<pre class="brush: js">var wm = new WeakMap();
+wm.set(window, "foo");
+
+wm.has(window); // returns true
+wm.has("baz"); // returns 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>{{SpecName('ES6', '#sec-weakmap.prototype.has', 'WeakMap.prototype.has')}}</td>
+ <td>{{Spec2('ES6')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-weakmap.prototype.has', 'WeakMap.prototype.has')}}</td>
+ <td>{{Spec2('ESDraft')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<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>{{CompatGeckoDesktop("6.0")}}</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>{{CompatGeckoMobile("6.0")}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatNo}}</td>
+ <td>8</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<h2 id="Firefox-特有说明">Firefox-特有说明</h2>
+
+<ul>
+ <li>直到SpiderMonkey 38 {{geckoRelease(38)}}, 这个方法在key参数不是一个对象时会抛出 {{jsxref("TypeError")}}。它已经从版本38后按照最新版本的ES6标准修复 ({{bug(1127827)}}).</li>
+</ul>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li>{{jsxref("WeakMap")}}</li>
+ <li>{{jsxref("WeakMap.prototype.set()")}}</li>
+ <li>{{jsxref("WeakMap.prototype.get()")}}</li>
+</ul>