promise.js
function each(collection, iterator) {
  for (var i = 0; i < collection.length; i++) {
    iterator(collection[i], i);
  }
}
function each(collection, iterator) {
  for (var i = 0; i < collection.length; i++) {
    iterator(collection[i], i);
  }
}
function each ( collection , iterator ) { for ( var i = 0 ; i < collection . length ; i ++ ) { iterator ( collection [ i ] , i ) ; } }
Iterates over each element of an array, calling the iterator with the
element and its index.

@param {!Array} collection
@param {function(*=,number)} iterator
Iterates over each element of an array calling the iterator with the element and its index .