arrow functions vs bind vs self (execution) (v2)

Revision 2 of this benchmark created on


Description

See how long it takes to execute.

Setup

var obj = { 
    
      val: 4,
    
      bind: function() {
        return function() {
          return this.val * this.val;
        }.bind( this ); 
      },
    
      self: function() {
        var self = this;
        return function() {
          return self.val * self.val;
        };
      },
    
      arrow: function() {
        return () => this.val * this.val;
      }
      
    };
    
    var bind = obj.bind();
    var self = obj.self();
    var arrow = obj.arrow();

Test runner

Ready to run.

Testing in
TestOps/sec
bind
bind();
ready
self
self();
ready
arrow
arrow();
ready

Revisions

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