main.js
1
2
3
4
5
6
7
8
9
10
const each = function(collection, iterator) {
  for (let i = 0; i < collection.length; i++) {
    iterator(collection[i], i, collection);
   }
  };
  

  
  // with ES6 function call
  each([1,2,3,4,5], item => console.log(item));
Native Browser JavaScript