JavaScript Foreach | JS Foreach | JavaScript Array Foreach Tutorial By WDH

JavaScript Foreach


JavaScript array foreach
In this Tutorial you will learn about JavaScript array foreach() method, The foreach() calls a function for each in an array element.
The Syntax of foreach() method is as follows: 
arrayName.forEach(function((element) => ( /* ... */ ))
Example1
Output
Example2
Output
Parameters
function()
Required.
A function to run for each array element.
currentValue
Required.
The value of the current element.
index
Optional.
The index of the current element.
arr
Optional.
The array of the current element.
thisValue
Optional. Default undefined.
A value passed to the function as its this value.