each
Iterate a List-like or Map-like, calling callback on each keyed or indexed property
each(obj, callback, context)
If obj is a List-like or an Iterator-like, each functions as eachIndex,
iterating over numeric indexes from 0 to obj.length - 1 and calling callback with each property and
index, optionally with context as this (defaulting to obj). If not, each functions as
eachKey,
iterating over every key on obj and calling callback on each one.
var foo = new DefineMap({ bar: "baz" });
var quux = new DefineList([ "thud", "jeek" ]);
canReflect.each(foo, console.log, console); // -> logs 'baz bar {foo}'
canReflect.each(quux, console.log, console); // -> logs 'thud 0 {quux}'; logs 'jeek 1 {quux}'
Parameters
- obj
{Object}:The object to iterate over
- callback
{function(*, ValueLike)}:a function that receives each item in the ListLike or MapLike
- context
{[}:an optional
thiscontext for calling the callback