bind vs closure (v49)

Revision 49 of this benchmark created by Paul on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/dojo/1/dojo/dojo.xd.js">
</script>
<script>
  function foo() {}
</script>

Setup

var binder = function(scope, method) {
    return function() {
      return method.apply(scope, arguments);
    }
  };

Teardown



            var test = (function() {
    return this
  }.bind(this));
  
  test;
  test();
        
  

Test runner

Ready to run.

Testing in
TestOps/sec
self
var self = this;
var test = function() {
  return self
};
test();
ready
bind()
var test = (function() {
  return this
}.bind(this));
test();
ready
dojo.hitch
var test = dojo.hitch(this, function() {
  return this
});
test();
ready
var test = binder(this, function() {
  return this
});
test();
ready
call (control)
var test = function() {
  return this
};
test.call(this);
ready

Revisions

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