array.forEach(fn.bind(context) vs. array.forEach(fn, context); (v2)

Revision 2 of this benchmark created by papandreou on


Preparation HTML

<script>
var testArray = (function() {
  var index = -1,
      length = 100,
      result = Array(length);

  while (++index < length) {
    result[index] = 'val' + index;
  }
  return result;
}());
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
forEach(fn.bind(ctx))
var blah = 0;
testArray.forEach(function(num) {
 blah += num;
}.bind(this));
ready
forEach(fn, ctx)
var blah = 0;
testArray.forEach(function(num) {
 blah += num;
}, this);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.