push vs concat vs slice

Benchmark created by Rahly on


Description

Fastest method of convert array-like to actual arrays

Setup

function pushtest() {
      var args = [];
      args.push.apply(args,arguments);
    }
    function concattest() {
      var args = [].concat.apply([],arguments);
    }
    function slicetest() {
      var args = [].slice.apply(arguments);
    }
    function slicecalltest() {
      var args = [].slice.call(arguments);
    }

Test runner

Ready to run.

Testing in
TestOps/sec
push
pushtest(1,2,3,4,5,6,7,8,9);
ready
concat
concattest(1,2,3,4,5,6,7,8,9);
ready
slice
slicetest(1,2,3,4,5,6,7,8,9);
ready
slice call
slicecalltest(1,2,3,4,5,6,7,8,9);
ready

Revisions

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