Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

4

722
Views
What does the map method do?

In JS map it is responsible for generating a response array from a function applied to an input array

over 4 years ago · José Alejandro Vargas Gutiérrez
12 answers
Answer question

0

Basically it allows you to loop through an object and/or an array of objects in a new item.

over 4 years ago · Sergio Andres Campbell Villarreal Report

0

Basically it allows you to loop through an object and/or an array of objects in a new item.

over 4 years ago · Sergio Andres Campbell Villarreal Report

0

Iterates through an object but returns numbers different from the original object

over 4 years ago · Jesus Miguel Tirado Puello Report

0

map allows you to manipulate an array response more efficiently without having to normally generate loops and whiles to iterate through all the vector items

over 4 years ago · Juan Burgos Herrera Report

0

CREATE A NEW ARRANGE STARTED WITH ANOTHER

over 4 years ago · MARVIN BLAS DE LA PEÑA GUZMAN Report

0

acts as a for

over 4 years ago · Valeria Lucia Navarro Garcia Report

0

In a nutshell, it walks through the placed array.

over 4 years ago · Iosef Dali Ayala Huaringa Report

11

In more descriptive terms it creates a new array with the results applied in the method.

Example:

We are going to map an array to find the numbers greater than 2.

we have our first array that we will call array1

 array1 = [1, 2, 3, 4]

To create the map method is as follows:

yourArray.map (receivesAnItem => returnsTheResultAppliedToYourElements)

So we're going to use the map method to find out which numbers are greater than 2.

 newArray = array1.map(num => num > 2)

This would return:

 console.log(newArray); result: [false, false, true, true]

In cases more developed in the labor field, it is used a lot for JSON, such as:

 myJson = [ { "name": "Pepito", "age": 20, }, { "name": "Juan", "age": 28 } ]

Let's map this JSON to get the names.

 newJson = myJson.map(item => item.name)

This would return a new array with the elements that would be the names.

 console.log(newJson); result: ['Pepito', 'Juan']

over 4 years ago · Santiago Trujillo Report

4

It goes through an array and returns a new one, with the result of the operations or processes applied to each item of the collection.

over 4 years ago · Yesid Dávila Sierra Report

5

The map method in Javascript allows us to use an array to create a new one, which is the result of the return of a function that we pass as an argument, in said function we can do any process on each element of the array, to then return an element that will be part of the new array.

 let nums = [1,5,6,8,7] let powOddNums = nums.map(function(element){ if(element % 2 !== 0 ){ return element * element } return element }) result: [1,25,6,8,49]
over 4 years ago · Carlos Yeric Fonseca Rios Report

1

The textual definition indicates that it creates a new array from an existing one, but this relative to what we do in the callback function is passed as an argument, you can even use the map without taking the result to a variable (myArray.map(element => {only view element})).

In conclusion, the map method loops through an array, extracting each element of an existing array in order.

over 4 years ago · Edwin Arley Gomez Mendez Report

1

The Map object holds key-value pairs and remembers the original insertion order of the keys. Any value (both objects and primitive values) may be used as either a key or a value.
A Map object iterates its elements in insertion order — a for...of loop returns an array of [key, value] for each iteration.

Objects vs. Maps

Object is similar to Map—both let you set keys to values, retrieve those values, delete keys, and detect whether something is stored at a key. For this reason (and because there were no built-in alternatives), Object has been used as Map historically.

However, there are important differences that make Map preferable in some cases:

If you want to learn more about map of javascript, please read this article.....
Good Luck...

over 4 years ago · Marko Kujacic Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!