Invokes a function once for each element in a collection.
When invoked, the input function is provided three arguments:
value
index
collection
input collection
function to invoke
execution context
function log( v, index, collection ) { console.log( '%s: %d', index, v ); } var arr = [ 1, 2, 3, 4 ]; forEach( arr, log );
Invokes a function once for each element in a collection.
Notes
When invoked, the input function is provided three arguments:
value
: collection valueindex
: collection indexcollection
: the input collection