Javascript ForEach() Function

The foreach() function of array object execute given method once for each element of array. The filter method of array object will creates a new array with all of the elements of this array for which the provided filtering function returns true. Use it for example to test each element of the array.

Syntax

Javascript ForEach() Function Example1

This will produce following result

Javascript ForEach() Function Example2

This will produce following result