Standard built-ins
Array.prototype.forEach()
Invokes a callback for present indices in ascending order and ignores its return values. Ordinary holes are skipped. No normal early break and no waiting for returned promises; use a loop for those needs.
Formal Syntax & Structure
javascript syntaxjavascript
array.forEach(callback, thisArg?)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| callback | function | Performs an action with value, index and source. |
| thisArg | any | Optional this value for ordinary callback functions. |
Return Value
undefined
Always undefined on normal completion.
Working Example
Example Snippetjavascript
const r=[2,4].forEach(x=>console.log(x)); console.log(r);