call vs apply (v85)

Revision 85 of this benchmark created by Pavel on


Setup

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

Test runner

Ready to run.

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

Revisions

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