arguments slice vs for

Benchmark created by N on


Setup

var ffor = function () {
      var len = arguments.length,
        ret = new Array(len);
    
      for (var i = 0; i < len; i++) {
        ret[i] = arguments[i];
      }
    
       return ret;
    };
    
    var fslice = function () {
      return Array.prototype.slice.call(arguments);
    }

Test runner

Ready to run.

Testing in
TestOps/sec
for
ffor(1, 2, 3, 4);
ready
slice.call
fslice(1, 2, 3, 4);
ready

Revisions

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