Array.push 2 (v3)

Revision 3 of this benchmark created on


Setup

var x = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p'],
        y = [];
        z = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p'];

Test runner

Ready to run.

Testing in
TestOps/sec
Push
y=[];
for (var i = 0; i < x.length; i++) {
  y.push(x[i]);
}
ready
Index
y=[];
for (var i = 0; i < x.length; i++) {
  y[y.length] = x[i];
}
ready
resize + index
z=[];
for (var i = 0; i < x.length; i++) {
  z[i] = x[i];
}
ready

Revisions

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