DEV Community

Discussion on: The 8 must know JavaScript looping array function

Collapse
orime112 profile image
Orime

Array.entries

let arr = [1, 2, 3]
let entriesLoop = arr.entries()
entriesLoop.next() // {value: [0, 1], done: false}
entriesLoop.next() // {value: [1, 2], done: false}
entriesLoop.next() // {value: [2, 3], done: false}
entriesLoop.next() // {value: undefined, done: true}
Enter fullscreen mode Exit fullscreen mode