call vs apply vs plain function (v18)

Revision 18 of this benchmark created on


Setup

function Obj() {
          var that = "that";
    }
    Obj.prototype.target = function(test) {
       return test;
    };
    var funcName = "target";
    var inObj = new Obj();
    var arr = ["YES"];
    var fn = function(test) {
       return test;
    };

Test runner

Ready to run.

Testing in
TestOps/sec
no context prototype apply
Obj.prototype.target.apply(null, ["YES"]);  
ready
no context prototype call
Obj.prototype.target.call(null, "YES");
ready
object function call
inObj.target('YES');
ready
with context plain function apply
fn.apply(inObj, ["YES"]);  
ready
no context plain function apply arr
fn.apply(null, arr);  
ready
no context plain function call
fn.call(null, "YES");  
ready
with context prototype apply
Obj.prototype.target.apply(inObj, ["YES"]);  
ready
with context prototype call
Obj.prototype.target.call(inObj, "YES");
ready
plain function
fn("YES");
ready
with context plain function call
fn.call(inObj, "YES");
ready
bracket context
inObj[funcName]("YES");
ready
bracket context call
inObj[funcName].call(inObj, "YES");
ready
bracket context apply
inObj[funcName].apply(inObj, ["YES"]);
ready

Revisions

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