call vs apply (v69)

Revision 69 of this benchmark created by Exo on


Setup

function Obj() {
      this.that = 'that';
    }
    
    Obj.prototype.target = function () {
      return 'that: ' + this.that + ', args: ' + Array.prototype.slice.call(arguments).join(' ,');
    };
    
    var myObj = new Obj();

Test runner

Ready to run.

Testing in
TestOps/sec
Call - 1 Argument
Obj.prototype.target.call(myObj, 'arg1');
ready
Apply - 1 Argument
Obj.prototype.target.apply(myObj, ['arg1']);
ready
Normal invocation
myObj.target('arg1');
ready
Call - 2 Arguments
Obj.prototype.target.call(myObj, 'arg1', 'arg2');
ready
Apply - 2 Arguments
Obj.prototype.target.apply(myObj, ['arg1', 'arg2']);
ready
Call - 3 Arguments
Obj.prototype.target.call(myObj, 'arg1', 'arg2', 'arg3');
ready
Apply - 3 Arguments
Obj.prototype.target.apply(myObj, ['arg1', 'arg2', 'arg3']);
ready
Call - 4 Arguments
Obj.prototype.target.call(myObj, 'arg1', 'arg2', 'arg3', 'arg4');
ready
Apply - 4 Arguments
Obj.prototype.target.apply(myObj, ['arg1', 'arg2', 'arg3', 'arg4']);
ready

Revisions

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