2019-04-21 11:50:48 +08:00

104 lines
4.2 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<article id="wikiArticle">
<div></div>
<p>entries() 方法返回一个新的迭代器对象 ,这个对象的元素是类似 [value, value] 形式的数组value 是集合对象中的每个元素,迭代器对象元素的顺序即集合对象中元素插入的顺序。由于集合对象不像 Map 对象那样拥有 key然而为了与 Map 对象的 API 形式保持一致,故使得每一个 entry 的 key 和 value 都拥有相同的值,因而最终返回一个 [value, value] 形式的数组。</p>
<h2 id="语法">语法</h2>
<pre><code class="language-javascript"><code><em>mySet</em>.entries()</code></code></pre>
<h3 id="返回值">返回值</h3>
<p>一个新的包含 [value, value] 形式的数组迭代器对象value 是给定集合中的每个元素,迭代器 对象元素的顺序即集合对象中元素插入的顺序。</p>
<h2 id="示例">示例</h2>
<h3 id="使用_entries()">使用 <code>entries()</code></h3>
<pre><code class="language-js">var mySet = new Set();
mySet.add("foobar");
mySet.add(1);
mySet.add("baz");
var setIter = mySet.entries();
console.log(setIter.next().value); // ["foobar", "foobar"]
console.log(setIter.next().value); // [1, 1]
console.log(setIter.next().value); // ["baz", "baz"]
</code></pre>
<h2 id="规范">规范</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">规范</th>
<th scope="col">状态</th>
<th scope="col">说明</th>
</tr>
<tr>
<td><a class="external" href="https://www.ecma-international.org/ecma-262/6.0/#sec-set.prototype.entries" hreflang="en" lang="en" rel="noopener">ECMAScript 2015 (6th Edition, ECMA-262)<br/><small lang="zh-CN">Set.prototype.entries</small></a></td>
<td><span class="spec-Standard">Standard</span></td>
<td>初始定义。</td>
</tr>
<tr>
<td><a class="external" href="https://tc39.github.io/ecma262/#sec-set.prototype.entries" hreflang="en" lang="en" rel="noopener">ECMAScript Latest Draft (ECMA-262)<br/><small lang="zh-CN">Set.prototype.entries</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/24" title="Released on 2013-09-17.">24</a> (24)</td>
<td><span style="color: #f00;">未实现</span></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>38</td>
<td>24.0 (24)</td>
<td><span style="color: #f00;">未实现</span></td>
<td><span style="color: #f00;">未实现</span></td>
<td>8</td>
</tr>
</tbody>
</table>
</div>
<h2 id="相关链接">相关链接</h2>
<ul>
<li><a class="new" href="Reference/Global_Objects/Set/keys" rel="nofollow" title="此页面仍未被本地化, 期待您的翻译!"><code>Set.prototype.keys()</code></a></li>
<li><a href="Reference/Global_Objects/Set/values" title="values() 方法返回一个 Iterator  对象,这个对象以插入 Set 对象的顺序包含了原 Set 对象里的每个元素。"><code>Set.prototype.values()</code></a></li>
</ul>
</article>