Here is an array example:
var arr = [0,1,2,3];
Is this code ...
for(var i = 0, l = arr.length; i < l; i++ ){
sum += arr[i];
}
equivalent to this code ...
arr.forEach(function(val)){
sum += val;
}
I would guess that they are functionally the same but one has better performance?
If so I would assume forEach is preferred as it is "cleaner", but a raw loop has better performance.