I was doing some reading about es2015, trying out some of the examples on the arrow syntax when I came across this code:
var odds = evens.map(v => v + 1);//I understand
var nums = evens.map((v,i) => v + i);//I don't understand
with evens initialized to [0,2,4,6] I get [1,3,5,7] from odds, which I understand.
However I don't understand the result of the the second expression [0,3,6,9]. Essentially I'm not understanding what values are being assigned to the variable i in the second example. Can anyone shed any light on this?
Array#map, in particular the part about what parameters it passes to the callback.