input object
function to invoke
execution context
obj - input object
function log( v, key ) {
console.log( '%s: %d', key, v );
}
function Foo() {
this.a = 1;
this.b = 2;
return this;
}
Foo.prototype.c = 3;
Foo.prototype.d = 4;
var obj = new Foo();
forIn( obj, log );
Invokes a function once for each own and inherited enumerable property of an object.
Notes
When invoked, the function is provided three arguments:
value
: object property valuekey
: object propertyobj
: the input objectTo terminate iteration before visiting all properties, the provided function must explicitly return
false
.Iteration order is not guaranteed.