can.each

  • function
 

Iterate through an array or object.

can.each(collection, callback)

Parameters

  1. collection {Object}

    The object to iterate through.

  2. callback {function()}

    A function to call for each item in collection. callback will recieve the item's value first and its key second.

can.each(collection, callback) iterates through an array or object like like jQuery.each.

can.each([{prop: "val1"}, {prop: "val2"}],
    function( value, index ) {
        // function called with
        // index=0 value={prop: "val1"}
        // index=1 value={prop: "val2"}
    }
);