“función de mapa” Código de respuesta

Índice de usin map map eS6

const array = [1, 2, 3, 4];


const map = array.map((x, index) => {
  console.log(index);
  return x + index;
});

console.log(map);
Graceful Grivet

función de mapa

const arr = [{name: "test"}, {name: "test1"}, {name: "test2"}]

arr.map((n, i) => {
	console.log(n);
})
Code Sir

Cómo usar el método de mapa en JavaScript

const numbers = [1, 2, 3, 4, 5]; 

const bigNumbers = numbers.map(number => {
  return number * 10;
});
TechWhizKid

mapa()

The map() method creates a new array populated with the results of calling 
a provided function on every element in the calling array.

const array1 = [1, 4, 9, 16];

// pass a function to map
const map1 = array1.map(x => x * 2);

console.log(map1);
// expected output: Array [2, 8, 18, 32]
CodeMaster64

función de mapa

# map function
city_lengths = map(len, ['sanjose', 'cupertino', 'sunnyvale', 'fremont'])
print(list(city_lengths))

# [7, 9, 9, 7]
# Map takes a function and a collection of items. It makes a new, empty collection, runs the function on each item in the original collection and inserts each return value into the new collection. It returns the new collection.
Impossible Impala

función de mapa

const ratings = watchList.map(item => ({
  title: item["Title"],
  rating: item["imdbRating"]
}));
Perfect Peccary

Respuestas similares a “función de mapa”

Preguntas similares a “función de mapa”

Más respuestas relacionadas con “función de mapa” en JavaScript

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código