JavaScript Array Type

Iteration

We can loop through all the elements of an array by using the forEach method. This method takes a function parameter and calls it once for every element in the array. It does not cause the array to mutate. The callback function should accept a value from the array.

const quote = [
"A",
"man",
"can",
"only",
"stumble",
"for",
"so",
"long",
"before",
"he",
"either",
"falls",
"or",
"stands",
"up",
"straight.",
]
quote.forEach(word => {
console.log(word.toUpperCase())
})

The example above calls the console.log function on every element in the array.

Read more on MDN

Array.prototype.forEach()