call vs apply (v61)

Revision 61 of this benchmark created by Quentin 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);
ready
Apply
var arg = "arg";
Obj.prototype.target.apply(myObj, []);
ready
Call 2
var arg = "arg";
myObj.target.call(myObj);
ready
Apply 2
var arg = "arg";
myObj.target.apply(myObj, []);
ready
Normal
var arg = "arg";
myObj.target();
ready
Braces
var arg = "arg";
myObj['target']();
ready

Revisions

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