Categories
JavaScript Answers

How to loop through an array without using array size with Node?

Spread the love

To loop through an array without using array size with Node, we use the forEach method.

For instance, we write

const myArray = ["1", "2", 3, 4];

myArray.forEach((value) => {
  console.log(value);
});

to call forEach with a callback that gets the entry in myArray being looped through.

We get the value being looped through from value.

By John Au-Yeung

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

Leave a Reply

Your email address will not be published. Required fields are marked *