push unallocated vs push preallocated

Edit on GitHub

Setup

var n=10000;
var myArray = [];
var myArray2 = new Array(n);

Tests

  • push unallocated

    var i=0;
    while (i<n) { myArray[i]=i; i++; }
  • push preallocated

    var i=0;
    while (i<n) { myArray2[i]=i; i++; }