* Iterates over elements of a collection, executing the callback for each * element. The callback is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). Callbacks may exit iteration early by * explicitly returning `false`. * * Note: As with
(collection, callback, thisArg)
| 38422 | * // => logs each number and returns the object (property order is not guaranteed across environments) |
| 38423 | */ |
| 38424 | function forEach(collection, callback, thisArg) { |
| 38425 | var index = -1, |
| 38426 | length = collection ? collection.length : 0; |
| 38427 | |
| 38428 | callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3); |
| 38429 | if (typeof length == 'number') { |
| 38430 | while (++index < length) { |
| 38431 | if (callback(collection[index], index, collection) === false) { |
| 38432 | break; |
| 38433 | } |
| 38434 | } |
| 38435 | } else { |
| 38436 | forOwn(collection, callback); |
| 38437 | } |
| 38438 | return collection; |
| 38439 | } |
| 38440 | |
| 38441 | /** |
| 38442 | * This method is like `_.forEach` except that it iterates over elements |
no test coverage detected