In this article, we’re going to walk through the many different ways to loop through arrays in JavaScript, from the native approach many will be familiar with, to more recent (and readable) methods introduced in ES6 and later. 

Native For-Loop

JavaScript

 

xxxxxxxxxx
1

 

1

let myArray = ["Hello,", "world!", "It's", "nice", "to", "meet", "you!"];

2

3

for(let i = 0; i < myArray.length; i++) {

4

    const currElem = myArray[i];

5

  

6

    console.log(`At index ${i}, our element is: ${currElem}`);

7

}

In this article, we’re going to walk through the many different ways to loop through arrays in JavaScript, from the native approach many will be familiar with, to more recent (and readable) methods introduced in ES6 and later. 
Native For-Loop

JavaScript

 

xxxxxxxxxx

1

 

1

let myArray = [“Hello,”, “world!”, “It’s”, “nice”, “to”, “meet”, “you!”];

2

3

for(let i = 0; i < myArray.length; i++) {

4

const currElem = myArray[i];

5

 

6

console.log(`At index ${i}, our element is: ${currElem}`);

7

} […]