Push vs [i] vs [this.length] (v10)

Revision 10 of this benchmark created by Diego Alvarez on


Description

is array.push(x) fast than array[array.length] = x ?

Setup

var array = [];
    var count = 5000;

Test runner

Ready to run.

Testing in
TestOps/sec
this.length
for ( var i = 0; i < count; i++ ) {

var item = {
   x: i,
   y: i
};
array[array.length] = item;
}
ready
Push
for( var i = 0; i < count; i++ ) {

var item = {
  x: i,
  y: i
};
array.push( item );
}
ready

Revisions

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