Probably the most elegant way to do this is to simply use Array.forEach :
a.forEach(function(someA, i) { calcRoute(fixedLocation, my_cities[i].address, function(response) {
The callback function is passed:
- current item
- current index
- the array to which it was called
Leaving the arguments simply means that you cannot access them in the callback. (Often you do not specify an index and just use the current element).
If a is a NodeList that does not have forEach , simply do:
Array.forEach.call(a, function(someA, i) { ... }
flying sheep
source share