bind vs closure (v39)

Revision 39 of this benchmark created on


Setup

foo = {};
    foo.setup = function () { 
      obj = {};
      var self = this;
      obj.closure = function() {
         return self;
      };
      obj.direct = function () {
         return this;
      };
  
      obj.bound = obj.direct.bind(this);
  
      return obj;
    };
  
    var x = foo.setup();

Test runner

Ready to run.

Testing in
TestOps/sec
bind()
x.bound() === foo;
ready
closure
x.closure() === foo;
ready
call
x.direct.call(foo) === foo;
ready
apply
x.direct.apply(foo) === foo;
ready

Revisions

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