JavaScript Answers

How to For-each over an array in JavaScript?

Spread the love

To For-each over an array in JavaScript, we use a for-of loop.

For instance, we write

const a = ["a", "b", "c"];
for (const element of a) {

to loop through the a array with the for-of loop.

We get the element being looped through from element.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published.