back to Overview

_.eachObj()

Invokes the given function once for each property of the given object.
Util module only.

Syntax Variants

_.eachObj(obj, callback)
_.eachObj(obj, callback, ctx)

Parameters

obj
the object to use
callback
The callback function(key, value) to invoke for each property.
key
The name of the current property.
value
The value of the current property.
this
The given context. If not set, the object itself.
The callback's return value will be ignored.
ctx (optional)
a context to pass to the callback as 'this'.
(return value)
the object

Description

Invokes the given function once for each property of the given object. The callback is not invoked for inherited properties.

Example

Dumps all properties of an object.

var s = '';
_.eachObj({a: 1, b: 5, c: 2}, function(key, value) {
    s += 'key=' + key + ' value=' + value + '
';
});

See also..

Comments

comments powered by Disqus

back to Overview

Functions