Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

123456789101112131415161718192021222324252627282930313233343536373839
  1. var baseFor = require('./_baseFor'),
  2. castFunction = require('./_castFunction'),
  3. keysIn = require('./keysIn');
  4. /**
  5. * Iterates over own and inherited enumerable string keyed properties of an
  6. * object and invokes `iteratee` for each property. The iteratee is invoked
  7. * with three arguments: (value, key, object). Iteratee functions may exit
  8. * iteration early by explicitly returning `false`.
  9. *
  10. * @static
  11. * @memberOf _
  12. * @since 0.3.0
  13. * @category Object
  14. * @param {Object} object The object to iterate over.
  15. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  16. * @returns {Object} Returns `object`.
  17. * @see _.forInRight
  18. * @example
  19. *
  20. * function Foo() {
  21. * this.a = 1;
  22. * this.b = 2;
  23. * }
  24. *
  25. * Foo.prototype.c = 3;
  26. *
  27. * _.forIn(new Foo, function(value, key) {
  28. * console.log(key);
  29. * });
  30. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  31. */
  32. function forIn(object, iteratee) {
  33. return object == null
  34. ? object
  35. : baseFor(object, castFunction(iteratee), keysIn);
  36. }
  37. module.exports = forIn;