Standard built-ins
Array.prototype.map()
Transforms present indices, retaining length and ordinary holes. The callback receives value, index and source; its returned value becomes a result element. Captures initial length, and subsequent reads can observe changes.
Formal Syntax & Structure
javascript syntaxjavascript
array.map(callback, thisArg?)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| callback | function | Computes the value for each present index. |
| thisArg | any | Optional this value for ordinary callback functions. |
Return Value
Array
New mapped array (ordinary array receiver).
Working Example
Example Snippetjavascript
console.log([1,3].map(n=>n*3).join(","));