call vs apply (v91)

Revision 91 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();
    
    var arrArg = ['string'];

Test runner

Ready to run.

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

Revisions

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