Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _['each'] = function(collection, iterator) {
- if (Array.isArray(collection) === false && typeof(collection) ===
- 'object') {
- var values = Object.values(collection);
- var keys = Object.keys(collection);
- for (let i = 0; i < values.length; i++) {
- iterator(values[i], keys[i], collection, i);
- }
- } else {
- for (let i = 0; i < collection.length; i++) {
- iterator(collection[i], i, collection);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement