forOwn.js 975 B

123456789101112131415161718192021222324252627282930313233
  1. var baseForOwn = require('../internal/baseForOwn'),
  2. createForOwn = require('../internal/createForOwn');
  3. /**
  4. * Iterates over own enumerable properties of an object invoking `iteratee`
  5. * for each property. The `iteratee` is bound to `thisArg` and invoked with
  6. * three arguments: (value, key, object). Iteratee functions may exit iteration
  7. * early by explicitly returning `false`.
  8. *
  9. * @static
  10. * @memberOf _
  11. * @category Object
  12. * @param {Object} object The object to iterate over.
  13. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  14. * @param {*} [thisArg] The `this` binding of `iteratee`.
  15. * @returns {Object} Returns `object`.
  16. * @example
  17. *
  18. * function Foo() {
  19. * this.a = 1;
  20. * this.b = 2;
  21. * }
  22. *
  23. * Foo.prototype.c = 3;
  24. *
  25. * _.forOwn(new Foo, function(value, key) {
  26. * console.log(key);
  27. * });
  28. * // => logs 'a' and 'b' (iteration order is not guaranteed)
  29. */
  30. var forOwn = createForOwn(baseForOwn);
  31. module.exports = forOwn;