eachIndex
Iterate a ListLike calling callback
on each numerically indexed element
eachIndex(list, callback, context)
For each numeric index from 0 to list.length - 1
, call callback
, passing the current
property value, the current index, and list
, and optionally setting this
as context
if specified (otherwise use the current property value).
var foo = new DefineList([ "bar", "baz" ]);
canReflect.eachIndex(foo, console.log, console); // -> logs 'bar 0 {foo}'; logs 'baz 1 {foo}'
Parameters
- list
{ListLike}
:The list to iterate over
- callback
{function(*, Number)}
:a function that receives each item
- context
{[}
:an optional
this
context for calling the callback
Returns
{ListLike}
:
the original list