I just started to learn JavaScript, and callback functions seem hard to understand. One question I have is how javascript matches the parameters in a callback function? for example in the following forEach loop:
var friends = ['Mike', 'Stacy', 'Andy', 'Rick'];
friends.forEach(function(eachName, index){
console.log(index + 1 + ". " + eachName);
});
Is it by default that the forEach function will pass index to the second parameter and entry to the first parameter in the callback function?
In order to master callback functions, do I need to check the API (in this case, forEach) every time I use it?