call vs apply (v82)

Revision 82 of this benchmark created by Thomas Steinke 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();
    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.