In this tutorial, you will learn all about JavaScript array forEach() Method & how to use this method.
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