DEV Community

Discussion on: Problems with Using for...in on Arrays in JavaScript

Collapse
 
imjoshellis profile image
Josh Ellis • Edited

An alternative that I didn't want to get into is using the index param from arr.forEach, but it is an option:

arr = [1, 2, 3]
arr.forEach((el, idx) => {
    n = idx + 5
    console.log(n) // 5, 6, 7
})