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

Benchmark created by papandreou on


Preparation HTML

<script>
  var testArray = [1, 2, 3, 4, 5, 6];
</script>

Test runner

Ready to run.

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

Revisions

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