--- 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 Iterator
객체를 반환합니다.
{{EmbedInteractiveExample("pages/js/array-entries.html")}}
arr.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']
Specification |
---|
{{SpecName('ESDraft', '#sec-array.prototype.entries', 'Array.prototype.entries')}} |
{{Compat("javascript.builtins.Array.entries")}}