spread apply vs apply (v15)

Revision 15 of this benchmark created by Spread Apply vs Apply on


Setup

function Obj() {
          var that = "that";
    }
    Obj.prototype.target = function(test) {
       return test;
    };

Test runner

Ready to run.

Testing in
TestOps/sec
apply
var val = ["1", "2", "3"];
Obj.prototype.target.apply(this, ["1", "2", "3"]);  
ready
modified apply
var val = ["1", "2", "3"];

switch(val.length)
{
case 0:
  Obj.prototype.target.call(this);
  break;
case 1:
  Obj.prototype.target.call(this, val[0]);
  break;
case 2:
  Obj.prototype.target.call(this, val[0]), val[1]);
  break;
case 3:
  Obj.prototype.target.call(this, val[0]), val[1], val[2]);
  break;
}
ready

Revisions

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