Standard built-ins

Array.prototype.map()

Try the free JavaScript compiler

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

NameTypeDescription
callbackfunctionComputes the value for each present index.
thisArganyOptional 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(","));
JavaScript Reference