forEach
Call a function for each element of a List.
list.forEach(callback[, thisArg])
Parameters
- 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. callback is not invoked for List elements that were never initialized.
- thisArg
{Object}
:the object to use as
this
inside the callback
forEach
calls a callback for each element in the List.
var list = new List([1, 2, 3]);
list.forEach(function(element, index, list) {
list.attr(index, element * element);
});
list.attr(); // [1, 4, 9]