“Kartenfunktion” Code-Antworten

ES6 -Karte usin Index

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


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

console.log(map);
Graceful Grivet

Kartenfunktion

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

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

Verwenden Sie die Kartenmethode in JavaScript

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

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

Karte()

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

Kartenfunktion

# 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

Kartenfunktion

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

Ähnliche Antworten wie “Kartenfunktion”

Fragen ähnlich wie “Kartenfunktion”

Weitere verwandte Antworten zu “Kartenfunktion” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen