Questions tagged by "io"


$0
 bounty
2
answers
Understanding parameters in an anonymous function (callback example)
5 years ago • support_man
There is an example in JavaScriptIsSexy for a simple callback that I'd like to understand a bit better: var friends = ["Mike", "Stacy", "Andy", "Rick"]; friends.forEach(function (eachName, index){ console.log(index + 1 + ". " + eachName); // 1. Mike, 2. Stacy, 3. Andy, 4. Rick​ }); In this case, how are the parameters eachName and index understood to mean the elements of the array (people's names as strings) and index numbers, respectively? ...
1 - 1 of 1 items