entries

Tags
변환
새로운 배열 생성
요약
[인덱스, 값] 형태의 Array Iterator 객체로 변환함. next()로 다음요소 접근 가능.
arr.entries()
  • [인덱스, 값] 형태로 만들어줌.
  • next()로 다음요소 접근 가능
const array1 = ['a', 'b', 'c']; const iterator1 = array1.entries(); console.log(iterator1.next().value); // expected output: Array [0, "a"] console.log(iterator1.next().value); // expected output: Array [1, "b"]