call vs apply (v24)

Revision 24 of this benchmark created by João Pinho on


Setup

function Obj() {
      this.that = "that";
    }
    Obj.prototype.target = function(test) {
      this.that = test;
    };
    
    function target2(test) {
      this.that = test;
    }
    
    function targetInContext( context,test) {
      context.that = test;
    }
    var inst = new Obj();

Test runner

Ready to run.

Testing in
TestOps/sec
apply
Obj.prototype.target.apply(inst, ["YES"]);
ready
call
Obj.prototype.target.call(inst, "YES");
ready
method call
inst.target("YES");
ready
fun call
target2.call(inst, "YES");
ready
targetInContext
targetInContext(inst, "YES");
ready

Revisions

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