main.js
1
2
3
4
5
6
7
const each = function(collection, iterator) { 
  for (let key in collection) { 
    iterator(collection[key], key, collection) ;
  }
};

each({1:'one', 2:'two', 3:'three', 4:'four', 5:'five'}, (item,index) => console.log(`value = ${item} : key =  ${index}`));
Native Browser JavaScript