var oldArray = [1, 2, 3];
var timesFour = oldArray.map(function(val){
return val * 4;
});
console.log(timesFour); // returns [4, 8, 12]
console.log(oldArray); // returns [1, 2, 3]
In our example the callback only uses the value of the array element (the val argument) but your callback can also include arguments for the index and array being acted on.
I don’t quite understand the second part of the passage where it talks about “arguments for the index and array being acted on”. Can someone explain that with some examples? Thank you!