--- title: Array.prototype.entries() slug: Web/JavaScript/Reference/Global_Objects/Array/entries tags: - Array - ECMAScript 2015 - Iterator - JavaScript - Method - Prototype translation_of: Web/JavaScript/Reference/Global_Objects/Array/entries ---
entries()
メソッドは、配列内の各要素に対するキー/値のペアを含む新しい Array イテレーターオブジェクトを返します。
array.entries()
新しい {{jsxref("Array")}} イテレーターオブジェクトを返します。
const a = ['a', 'b', 'c']; for (const [index, element] of a.entries()) console.log(index, element); // 0 'a' // 1 'b' // 2 'c'
var a = ['a', 'b', 'c']; var iterator = a.entries(); for (let e of iterator) { console.log(e); } // [0, 'a'] // [1, 'b'] // [2, 'c']
仕様書 |
---|
{{SpecName('ESDraft', '#sec-array.prototype.entries', 'Array.prototype.entries')}} |
{{Compat("javascript.builtins.Array.entries")}}