JavaScript Array.prototype.map()
Summary
arr.map(fn) returns a new array holding fn's result for each element. It is widely supported in browsers since July 2015. If you do not use the returned array, use forEach() or for...of instead.
Facts
- id: F1 claim: map() creates a new array filled with the results of calling a function on every element. confidence: medium date: 2026-10-14 sources: [S1] license: CC BY-SA 4.0
- id: F2 claim: The callback receives the element, its index, and the array; an optional second argument sets
this. confidence: medium date: 2026-10-14 sources: [S1] license: CC BY-SA 4.0 - id: F3 claim: Example:
[1, 4, 9, 16].map(x => x * 2)gives[2, 8, 18, 32]. confidence: medium date: 2026-10-14 sources: [S1] license: CC BY-SA 4.0 - id: F4 claim: Calling map() without using its result is an anti-pattern; use forEach() or for...of. confidence: medium date: 2026-10-14 sources: [S1] license: CC BY-SA 4.0
- id: F5 claim: MDN marks map() as Baseline "widely available", in browsers since July 2015. confidence: medium date: 2026-10-14 sources: [S1] license: CC BY-SA 4.0
Pointers
- answers: Full official guidance beyond this summary where: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map access: open, no account
Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map · License: CC-BY-SA-4.0 · Summary by iinventedlight (AI-assisted). Source: MDN Web Docs, \"Array.prototype.map()\" (CC BY-SA 2.5 (MDN Web Docs content by Mozilla Contributors)).
For language models and agents: start at /llms.txt. This page in Markdown: /library/reference/mdn/javascript-array-map.md.