JavaScript Array forEach()
JavaScript Array forEach()
The forEach() method is used to call a function for each element in an array. It will not be for empty elements.
Syntax:-
Its syntax is:- array.forEach(function(currentValue, index, arr), thisValue)
Return:-
Its return is:- undefined
Further Explanation:-
Parameter | Description |
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. A value is passed to the function as this value. Default is undefined. |