In this tutorial, you will learn all about JavaScript array forEach() Method & how to use this method.

JavaScript array.forEach()

Usually, when you have a javascript array.

See the following:

let nums = [1, 2, 3, 4];

And want to call a function on each element of an array, at that time, you use javascript for loop statement.

For example, see the following code:

let nums = [1, 2, 3, 4]; 
for (let i = 0; i < nums.length; i++) {
    console.log(nums[i]);
}
Output:

1
2
3
4

https://www.tutsmake.com/learn-javascript-foreach-method/

JavaScript Calls Function For Each Element of an Array Example
1.50 GEEK