call vs apply (v11)

Revision 11 of this benchmark created on


Setup

function Obj() {
      var that = "that";
    }
    Obj.prototype.target = function(arg) {
      var string = "that: " + this.that + ", arg: " + arg;
      return string;
    };
    
    var myObj = new Obj(),
        that = {that: "that"},
        arg = "arg";
    
    var func = Obj.prototype.target;

Test runner

Ready to run.

Testing in
TestOps/sec
Call
func.call(that, arg);
ready
Apply
Obj.prototype.target.apply(that, [arg]);
ready
Normal invocation
new Obj().target(arg);
ready
Normal invocation cached Obj
myObj.target(arg);
ready

Revisions

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