Array.forEach

Function/Meaning

Executes the argument function for each element of the array.

Type
Arrayclassmethod of
Syntax
forEach(func, args) :variant
Arguments
func

In the case of a string, that method of the array element is called, and in the case of a function, it is called in the form of function (value, index, args *).

args

Specify any number of arguments to pass to the function to call. It does not have to be.

Return value

The value returned by the calling function

Explanation

Calls the specified function once for each element of the array.
If the context is null, such as an anonymous function, it will be called in the array context.
If the function returns a value, processing is interrupted and that value is used as the return value of this function.
When the function is called as a string, the method of all array elements is called without interruption even if the value is returned.