Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. _['each'] = function(collection, iterator) {
  2. if (Array.isArray(collection) === false && typeof(collection) ===
  3. 'object') {
  4. var values = Object.values(collection);
  5. var keys = Object.keys(collection);
  6. for (let i = 0; i < values.length; i++) {
  7. iterator(values[i], keys[i], collection, i);
  8. }
  9. } else {
  10. for (let i = 0; i < collection.length; i++) {
  11. iterator(collection[i], i, collection);
  12. }
  13. }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement