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

Revision 7 of this benchmark created 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))
this.blah = 0;
testArray.forEach(function(num) {
 this.blah += num;
}.bind(this));
ready
forEach(fn, ctx)
this.blah = 0;
testArray.forEach(function(num) {
 this.blah += num;
}, this);
ready
this.blah = 0;
var self = this;
testArray.forEach(function(num) {
 self.blah += num;
});
ready

Revisions

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