服务器

Array

Collection

Date

Function

Lang

Math

Number

Object

Seq

String

Util

Properties

Methods

_.forIn(object, iteratee=_.identity)

迭代对象的自己和继承的可枚举字符串键控属性,并iteratee为每个属性调用。迭代器被调用三个参数:(value,key,object)。迭代器函数可以通过显式返回提前退出迭代false

版本

0.3.0

参数
  1. object (Object):迭代的对象。
  2. [iteratee=_.identity] (Function):每次迭代调用的函数。
返回

(对象):返回object

function Foo() {
  this.a = 1;
  this.b = 2;
}
 
Foo.prototype.c = 3;
 
_.forIn(new Foo, function(value, key) {
  console.log(key);
});
// => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).