We can declare the forEach() method as below.
The forEach() method executes the provided callback once for each element present in the array in ascending order.
1. callback: It is a function used to test for each element. The callback function accepts three arguments, which are given below.
Note: These three arguments are optional.
2. thisObject: It is an object to use as this when executing the callback.
It will return the created array.
Example with string
Example with number
Disadvantage of forEach()
The following are the disadvantages of the use of the forEach() method: