Unshift item inside an array (v12)

Revision 12 of this benchmark created by kev on


Setup

var arr = [1, 2, 3, 4, 5, 6, 7];
  
  function fn_unshift() {
    arr.unshift(0);
    return arr;
  }
  
  function fn_concat_init() {
    return [0].concat(arr)
  }

Test runner

Ready to run.

Testing in
TestOps/sec
Add element at the init of Array with unshift()
fn_unshift()
ready
Add element at the init of Array with concat()
fn_concat_init()
ready

Revisions

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