call vs apply (v41)

Revision 41 of this benchmark created on


Setup

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

Test runner

Ready to run.

Testing in
TestOps/sec
Call
Obj.prototype.target.call(myObj, "one", "two");
ready
Apply
Obj.prototype.target.call(myObj, ["one", "two"]);
ready
Call 2
myObj.target.call(myObj, "one", "two");
ready
Apply 2
myObj.target.apply(myObj, ["one", "two"]);
ready
Normal
myObj.target("one", "two");
ready
Braces
myObj['target']("one", "two");
ready

Revisions

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