Map an array with this props

I’m struggling with map property, I mean I’m french, and the translation is obscure.
Someone can explain me with an example the meaning in English.

It would really help if you could tell us what you understand and which parts confuse you. allows you to provide a function that will transform every element into an array and replace it with the result of that function.

I understood the method and the way to use it, it’s Javascript functionnal.
But it’s more the English I don’t understand.
What’s mean map, I tought it was mean, an us map or Island map.
ex: " in JavaScript and allows you to “map” over an array"

Ah. I’m guessing that the origin of the name “map” comes from the fact the callback function creates what we would call “a one-to-one mapping of values,” meaning for every input there is exactly one predictable output. In the example used on MDN, they are creating squares. In that situation we would say that “two maps to four, three maps to nine,” and so on.

1 Like

Another way of saying this is:

" in JavaScript and allows you to **iterate** over an array"
1 Like

I can say, a map is a synonym to iterate?
It helps to understand even if it still obscure :confused:

Mapping word still :confused: me…

EDIT: After reading again, I got it, thanks
Btw, I don’t think we have this expression in French?

I was just trying to get you to understand what “mapping” over an array is like. It is best to read the documentation for what map does. See here.

I think map is best explained with a simple example.

If I created an array as below:

var arr = [1,2,3,4,5];

and then I wanted to created a new array (called newArr) which needed to contain the values of the original array (arr) plus 100, then I could do that with the following code:

var newArr = [];
for (var i = 0; i < arr.length; i++) {

I could also use map to do exactly the same thing:

var newArr = {
  return val + 100;

or using the ES6 arrow function syntax as:

var newArr = => val + 100);

All of the above pieces of code create a new array (called newArr) with the following values:

[ 101, 102, 103, 104, 105 ]

I haven’t problem to understand the prototype it self, thanks anyway.

I think that’s a good description. :thumbsup:

I would go just one step further by saying “iterate and change”… because that’s what you usually do with map. You create a new array by iterating over each item and changing it to something new.

Also, the MDN docs are available in French. :slight_smile:

1 Like

in French, I forgot about this feature :blush: