Array.push vs Array[Array.length] (v13)

Revision 13 of this benchmark created on


Setup

var result = [];
    var iterations = 1000;

Test runner

Ready to run.

Testing in
TestOps/sec
Array.push
result = [];
for (var i = 0; i < iterations;) {
  result.push(++i);
};
ready
Array.length
result = [];
for (var i = 0; i < iterations;) {
  result[result.length] = ++i;
};
ready
Array[i++]
result = [];
for (var i = 0; i < iterations;) {
  result[++i] = i;
};
ready

Revisions

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