Array.forEach
forEach — Executes a provided function once per array element.
Description
Array.forEach(function callback, [object this])
Parameters
Name | Description | Type | Default | Optional |
---|---|---|---|---|
callback | See callback below. | function | No | |
this | object | Yes |
callback
The following parameters is passed to the callback.
- value
The value of the current index.
- index
The current index.
- array
The array.
Examples
Example #1 – forEach example
Passing in a custom object for this.