call vs apply (v7)

Revision 7 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
Eval invocation
var arg = "arg";
var functionVar = function () { var that = "that";}
eval(functionVar)(arg);
ready
var arg = "arg";
var functionVar = function () { var that = "that";}
functionVar.call(arg);
ready

Revisions

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