call vs apply (v68)

Revision 68 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();

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, [arg]);
ready
Call 2
var arg = "arg";
myObj.target.call(myObj, arg);
ready
Apply 2
var arg = "arg";
myObj.target.apply(myObj, [arg]);
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.