call vs apply (v9)

Revision 9 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 that = {that: "that"};
var arg = "arg";
Obj.prototype.target.call(that, arg);
ready
Apply
var that = {that: "that"};
var arg = "arg";
Obj.prototype.target.apply(that, [arg]);
ready
Normal invocation
var arg = "arg";
new Obj().target(arg);
ready
Normal invocation cached Obj
var arg = "arg";
myObj.target(arg);
ready
call (no arg)
var that = {that: "that"};
Obj.prototype.target.call(that);
ready
apply (no arg)
var that = {that: "that"};
Obj.prototype.target.apply(that);
ready

Revisions

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