Array push() vs unshift() to existing (v17)

Revision 17 of this benchmark created on


Description

Tests the performance of reverse, push, reverse and unshift for adding an element to the start of an existing array.

Setup

var arr = [0, 1, 2, 3];

Teardown


    var arr = [0, 1, 2, 3];
  

Test runner

Ready to run.

Testing in
TestOps/sec
push()
arr.push(4);
 
ready
unshift()
arr.unshift(4);
ready
index assignment
arr[arr.length] = 4;
ready

Revisions

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