🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › map
Array.prototype.map() - JavaScript | MDN
July 12, 2026 - The map() method of Array instances creates a new array populated with the results of calling a provided function on every element in the calling array.
🌐
W3Schools
w3schools.com › jsref › jsref_map.asp
JavaScript Array map() Method
Return a new array with the square root of all element values.
🌐
Reddit
reddit.com › r/learnjavascript › what does the .map() function actually do?
r/learnjavascript on Reddit: What does the .map() function actually do?
November 3, 2022 -

Hello,

I have been learning javscript since April this year and recently I've got an exercise with matrices, with the condition to use .map() function explicitly.

Now, my question is, what does the .map() function actually do? Is it something like the console.log()? I don't want to use callbacks at the moment, but I have to figure out how to rotate a matrix clockwise and anti-clockwise.

I can do a vertical and horizontal flip for now, but I don't really see, how can I use .map() without introducing a for loop. Do i necessarily need a callback or a helper function as well?

Thank you anticipated.

🌐
Akamai
akamai.com › cloud › guides › how-to-use-javascript-map-function
How to Use the JavaScript Map() Function to Transform Arrays | Linode Docs
April 3, 2023 - Using the map() function is a good approach whenever an algorithm must derive a second array from the initial set of values. Some examples of typical use cases include transforming numerical data, manipulating strings, and generating HTML code. The following examples illustrate some common use cases. The example below uses the JavaScript map() function for numerical processing.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Map
Map - JavaScript | MDN
August 13, 2026 - Map objects are collections of key-value pairs. A key in the Map may only occur once; it is unique in the Map's collection. A Map object is iterated by key-value pairs — a for...of loop returns a 2-member array of [key, value] for each iteration.
🌐
Stack Overflow
stackoverflow.com › questions › 17367889 › what-is-the-concept-of-array-map
javascript - What is the concept of Array.map? - Stack Overflow
I am having problems understanding the concept of Array.map. I did go to Mozilla and Tutorials Point, but they provided very limited info regarding this. This is how I am using Array.map. It is a l...
🌐
Robin Wieruch
robinwieruch.de › javascript-map-array
Deep Dive into JavaScript's Array Map Method - Robin Wieruch
March 6, 2019 - An extensive walkthrough for JavaScript developers who want to get to know the Array's Map Method to transform data. You will learn about the Callback Function's Arguments, usages of Map with other Array Methods, and ...
🌐
Medium
medium.com › poka-techblog › simplify-your-javascript-use-map-reduce-and-filter-bd02c593cc2d
Simplify your JavaScript – Use .map(), .reduce(), and .filter() | by Etienne Talbot | poka-techblog | Medium
September 4, 2019 - So how does .map() work? Basically is takes 2 arguments, a callback and an optional context (will be considered as this in the callback) which I did not use in the previous example. The callback runs for each value in the array and returns each new value in the resulting array.
Find elsewhere
🌐
Medium
medium.com › @SoraEagle › javascript-the-map-array-method-c5bcdc6d9cb3
Javascript: The .map() Array Method | by Matthew Phillips | Medium
November 10, 2021 - Actually, .map() creates a copy of the original array, and allows you to transform it.
🌐
Medium
adam-drake-frontend-developer.medium.com › a-deep-dive-into-the-javascript-map-method-048f6eadf1b2
A Deep Dive into the Javascript map() Method | by Adam Drake | Medium
January 15, 2024 - According to the MDN documentation on the map() method, the map() method of Array instances creates a new array populated with the results of calling a provided function on every element in the calling array.
🌐
Mimo
mimo.org › glossary › javascript › map
JavaScript Map Function: Examples for Data Transformation
The .map() method creates a new array by calling a provided function on every element in the original array. It takes each element, transforms it according to the function, and adds the result to the new array. The original array remains unchanged. ... Become a full-stack developer.
🌐
DigitalOcean
digitalocean.com › community › tutorials › 4-uses-of-javascripts-arraymap-you-should-know
How to Use the JavaScript .map() Method | DigitalOcean
Learn how to use the JavaScript .map() method to transform arrays with clear examples, syntax explanations, and practical use cases.
🌐
Programiz
programiz.com › javascript › library › array › map
JavaScript Array map()
Returns a new array with elements as the return values from the callback function for each element. ... let newPrices = prices.map(Math.sqrt); // [ 42.42640687119285, 44.721359549995796, 54.772255750516614, // 70.71067811865476, 22.360679774997898, 89.44271909999159 ] console.log(newPrices); // custom arrow function const string = "JavaScript"; const stringArr = string.split(''); // array with individual string character
Top answer
1 of 3
2

The .map() function will go through the entire array, and on each step of that process it will take the current item that we are looking at and will pass it as a parameter into the function. You can then do whatever you want to that item, and whatever you return from your function will replace what is in that position in the array.

Say for example, with the array you gave in your question, we wanted to remove the name and last_name properties, and combine them into a full_name property. We can do the following:

 let people = [
   {
     id: 1,
     name: 'jhon',
     last_name: 'wilson'
   },
   {
     id: 2,
     name: 'maria',
     last_name: 'anyway'
   },
     id: 3,
     name: 'lastOne',
     last_name: 'example'
   }
];

people = people.map((person) => {
  return {
    id: person.id,
    full_name: `${person.name} ${person.last_name}`
  }
});

After this code runs, our people array would look like this:

[
   {
     id: 1,
     full_name: 'jhon wilson'
   },
   {
     id: 2,
     full_name: 'maria anyway'
   },
     id: 3,
     name: 'lastOne example'
   }
];

You can think of it as doing something very similar to this:

function transformPerson(person) {
  return {
    id: person.id,
    full_name: `${person.name} ${person.last_name}`
  }
}

let newPeople = [];
for (let i = 0; i < people.length; i++) {
  newPeople[i] = transformPerson(people[i])
}

people = newPeople;
2 of 3
0

Array.map() takes in a function as a parameter, passes each item of the array into the function, and returns an array of the result.

For example, if I wanted to multiply each of the items in the array by 2:

const x = [1, 2, 3, 4, 5]
const y = x.map(v => v * 2) // result: [2, 4, 6, 8, 10]

Note: Array.map does not affect the original array; it creates a new array of the results.

🌐
JavaScript.info
javascript.info › tutorial › the javascript language › data types
Map and Set
So we get a plain object with same key/values as the map. A Set is a special type collection – “set of values” (without keys), where each value may occur only once. ... new Set([iterable]) – creates the set, and if an iterable object is provided (usually an array), copies values from it into the set.
🌐
freeCodeCamp
freecodecamp.org › news › javascript-map-how-to-use-the-js-map-function-array-method
JavaScript Map – How to Use the JS .map() Function (Array Method)
March 31, 2021 - The Array.map() method allows you to iterate over an array and modify its elements using a callback function.
🌐
freeCodeCamp
forum.freecodecamp.org › curriculum help
Array.map in Javascript - Curriculum Help - The freeCodeCamp Forum
February 1, 2022 - let arr=[2,3,4]; let modArr=arr.map(function(element,index,array){ console.log(element); console.log(index); console.log(array); return element; },80); console.log(modArr); I want to know if it supposed to modif…
🌐
Medium
medium.com › @sagarkarotia › what-is-map-in-javascript-3a5cbddf476d
What is map() in JavaScript?. map() is an array method that creates a… | by Sagar | Medium
December 12, 2025 - What is map() in JavaScript? map() is an array method that creates a new array by applying a function to each element of the original array. ✔ It does NOT modify the original array. ✔ It always …
🌐
Educative
educative.io › blog › javascript-array-methods-map-reduce
JavaScript array methods: How to use the map and reduce
The map() method applies a function to each array element, creating a new array with the returned values. It’s ideal for tasks like transforming data, calculating square roots, or generating ASCII values.
🌐
freeCodeCamp
freecodecamp.org › news › array-map-tutorial
JavaScript Array.map() Tutorial – How to Iterate Through Elements in an Array with map()
October 15, 2024 - Array.prototype.map() is a built-in array method for iterating through the elements inside an array collection in JavaScript.