• function

forEach can.Observe.List.prototype.forEach

 

Call a function for each element of a List.

list.forEach(callback[, thisArg])

Parameters

  1. callback {function(element, index, list)}

    a function to call with each element of the List The three parameters that callback gets passed are element, the element at index, index the current element of the list, and list the List the elements are coming from.

  2. thisArg {Object}Optional

    the object to use as this inside the callback

forEach calls a callback for each element in the List.

var list = new can.Observe.List([1, 2, 3]);
list.forEach(function(element, index, list) {
    list.attr(index, element * element);
});
list.attr(); // [1, 4, 9]