bind vs that

Benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js"></script>
<script>
  var a = [];
  for (var i = 0; i < 999; i++) {
   a.push(i);
  }
  
  var me = {
   value: 123
  };
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
bind
a.forEach(function() {
 a.forEach(function() {
  return this.value;
 }.bind(me));
}.bind(me));
ready
that
a.forEach(function() {
 a.forEach(function() {
  return me.value;
 });
});
ready
forEach ctx
a.forEach(function() {
 a.forEach(function() {
  return this.value;
 }, me);
}, me);
ready

Revisions

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