4 ms·
Another example is: _.forEach(array, function(item) { doSomething(); if (condition) { // exits iteration early return false;
by mathias 13y ago
Another example is:
_.forEach(array, function(item) {
doSomething();
if (condition) {
// exits iteration early
return false;
}
});
This is just not possible with native `Array#forEach` – you’d have to use a plain `for` loop with a conditional `break` statement instead, or rewrite your code to use `Array#some`.