javascript array push performance (v3)

Revision 3 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
push one at a time
var arr = [];
arr.push(1);
arr.push(2);
arr.push(3);
arr.push(4);
arr.push(5);
ready
push many at a time
var arr = [];
arr.push(1, 2, 3, 4, 5);
ready
concat
var arr = [];
arr.concat([1, 2, 3, 4, 5]);
ready
assign in for loop
var ii, arr = [];
for (ii = 1; ii <= 5; ++ii) {
    arr[ii] = ii;
}
 
ready
push in for loop
var ii, arr = [];
for (ii = 1; ii <= 5; ++ii) {
    arr.push(ii);
}
 
ready

Revisions

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