1 var arrayEach = require('../internal/arrayEach'),
2 baseEach = require('../internal/baseEach'),
3 createForEach = require('../internal/createForEach');
6 * Iterates over elements of `collection` invoking `iteratee` for each element.
7 * The `iteratee` is bound to `thisArg` and invoked with three arguments:
8 * (value, index|key, collection). Iteratee functions may exit iteration early
9 * by explicitly returning `false`.
11 * **Note:** As with other "Collections" methods, objects with a "length" property
12 * are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn`
13 * may be used for object iteration.
18 * @category Collection
19 * @param {Array|Object|string} collection The collection to iterate over.
20 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
21 * @param {*} [thisArg] The `this` binding of `iteratee`.
22 * @returns {Array|Object|string} Returns `collection`.
25 * _([1, 2]).forEach(function(n) {
28 * // => logs each value from left to right and returns the array
30 * _.forEach({ 'a': 1, 'b': 2 }, function(n, key) {
31 * console.log(n, key);
33 * // => logs each value-key pair and returns the object (iteration order is not guaranteed)
35 var forEach = createForEach(arrayEach, baseEach);
37 module.exports = forEach;