Underscore: each

each pass

1
2
3
4
5
6
7
8
9
10
11
12
_.each = function(collection, iterator) {
if (Array.isArray(collection)) {
for (let index = 0; index < collection.length; index++) {
iterator(collection[index], Number(index), collection);
}
} else {
for (let key in collection) {
if (key !== 'someProperty')
iterator(collection[key], key, collection);
}
}
};
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×