Test case details

Preparation Code

<script>   var i, values = [],       sum = 0;   for (i = 0; i < 10000; i++) {    values[i] = i;   }     function add(val) {    sum += val;   } </script>

Test cases

Test #1

values.forEach(add);

Test #2

Array.prototype.forEach = function forEach(fn, thisContext) {   var iterator = thisContext !== undefined ? fn.bind(thisContext) : fn,     length = iterator ? this.length : 0,     i;   for (i = 0; i < length; i++) {     iterator(this[i], i, this);   } };