迭代对象的自身枚举字符串键控属性并iteratee
为每个属性调用。迭代器被调用三个参数:(value,key,object)。迭代器函数可以通过显式返回提前退出迭代false
。
0.3.0
object
(Object):迭代的对象。 [iteratee=_.identity]
(Function):每次迭代调用的函数。 (对象):返回object
。
function Foo() { this.a = 1; this.b = 2; } Foo.prototype.c = 3; _.forOwn(new Foo, function(value, key) { console.log(key); }); // => Logs 'a' then 'b' (iteration order is not guaranteed).Try in REPL