Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 705867 of Array.prototype.entries()

  • Revision slug: Web/JavaScript/Reference/Global_Objects/Array/entries
  • Revision title: Array.prototype.entries()
  • Revision id: 705867
  • Created:
  • Creator: arai
  • Is current revision? No
  • Comment

Revision Content

{{JSRef("Global_Objects", "Array")}} {{harmony}}

Summary

The entries() method returns a new Array Iterator object that contains the key/value pairs for each index in the array.

Syntax

arr.entries()

Examples

var arr = ['a', 'b', 'c'];
var eArr = arr.entries();

console.log(eArr.next().value); // [0, 'a']
console.log(eArr.next().value); // [1, 'b']
console.log(eArr.next().value); // [2, 'c']

Specifications

Specification Status Comment
{{SpecName('ES6', '#sec-array.prototype.entries', 'Array.prototype.entries')}} {{Spec2('ES6')}} Initial definition.

Browser compatibility

{{CompatibilityTable}}
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{CompatChrome("38")}} {{CompatGeckoDesktop("28")}} {{CompatNo}} {{CompatOpera("25")}} {{CompatSafari("7.1")}}
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatNo}} {{CompatNo}} {{CompatGeckoMobile("28")}} {{CompatNo}} {{CompatNo}} iOS 8

See also

  • {{jsxref("Array.prototype.keys()")}}
  • {{jsxref("Array.prototype.forEach()")}}
  • {{jsxref("Array.prototype.every()")}}
  • {{jsxref("Array.prototype.some()")}}

Revision Source

<div>
 {{JSRef("Global_Objects", "Array")}} {{harmony}}</div>
<h2 id="Summary" name="Summary">Summary</h2>
<p>The <code><strong>entries()</strong></code> method returns a new <code><strong>Array Iterator</strong></code> object that contains the key/value pairs for each index in the array.</p>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="syntaxbox">
<code><var>arr</var>.entries()</code></pre>
<h2 id="Examples" name="Examples">Examples</h2>
<pre class="brush:js">
var arr = ['a', 'b', 'c'];
var eArr = arr.entries();

console.log(eArr.next().value); // [0, 'a']
console.log(eArr.next().value); // [1, 'b']
console.log(eArr.next().value); // [2, 'c']
</pre>
<h2 id="Specifications" name="Specifications">Specifications</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-array.prototype.entries', 'Array.prototype.entries')}}</td>
   <td>{{Spec2('ES6')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>
<h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2>
<div>
 {{CompatibilityTable}}</div>
<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>{{CompatChrome("38")}}</td>
    <td>{{CompatGeckoDesktop("28")}}</td>
    <td>{{CompatNo}}</td>
    <td>{{CompatOpera("25")}}</td>
    <td>{{CompatSafari("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>{{CompatNo}}</td>
    <td>{{CompatNo}}</td>
    <td>{{CompatGeckoMobile("28")}}</td>
    <td>{{CompatNo}}</td>
    <td>{{CompatNo}}</td>
    <td>iOS 8</td>
   </tr>
  </tbody>
 </table>
</div>
<h2 id="See_also" name="See_also">See also</h2>
<ul>
 <li>{{jsxref("Array.prototype.keys()")}}</li>
 <li>{{jsxref("Array.prototype.forEach()")}}</li>
 <li>{{jsxref("Array.prototype.every()")}}</li>
 <li>{{jsxref("Array.prototype.some()")}}</li>
</ul>
Revert to this revision