JS
var arr = new Array(1,2,3,4,5); var sum = 0; var ret = arr.forEach(function(x) {sum += x;}); alert(sum); //15 alert(ret); //undefined
The function can take 3 arguments in the order of value, index (optional) and the array (optional).
var arr = new Array(1,2,3,4,5); arr.forEach(function(val,indx,arr){arr[indx] *= 2;}) alert(arr); //2,4,6,8,10