Push item inside an array

Benchmark created by joel on


Setup

var arr = [1, 2, 3, 4, 5, 6, 7];
  
  function fn_push() {
    arr.push(8);
  }
  
  function fn_push_manually() {
    arr[arr.length] = 8;
  }
  
  function fn_concat_end() {
    arr.concat([8])
  }

Teardown



            var arr = [1, 2, 3, 4, 5, 6, 7];
        
  

Test runner

Ready to run.

Testing in
TestOps/sec
Add element at the end of Array with push()
fn_push()
ready
Add element at the end of Array using the length property
fn_push_manually()
ready
Add element at the end of Array with concat()
fn_concat_end()
ready

Revisions

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