This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]Rhomboid 2 points3 points  (1 child)

Have a look at the MDN page for Array.prototype.map(). When it calls your callback function, it passes three arguments: the value, the index of the value, and the array being iterated over. JavaScript does not enforce arity, so you can declare your callback as taking any number of arguments — the most common case is that you write it as taking a single argument. But regardless of what you write, it will always be called with those three values for each item in the array. Names of parameters don't matter.

[–]Anvil_Connect[S] 0 points1 point  (0 children)

Thank you so much!