Run details:
Mozilla/5.0 (Android 5.0.1; Mobile; rv:47.0) Gecko/47.0 Firefox/47.0
Firefox Mobile 47
Android 5.0.1
Other
8 years ago
Test name Executions per second
Literal with push 29293.9 Ops/sec
Constructor() with push 35772.4 Ops/sec
Constructor(times) with push 17113.1 Ops/sec
Literal with index 27947.1 Ops/sec
Constructor() with index 32031.6 Ops/sec
Constructor(times) with index 23458.8 Ops/sec
Literal with push and overflow 25828.2 Ops/sec
Constructor() with push and overflow 31200.4 Ops/sec
Constructor(times) with push and overflow 15159.5 Ops/sec
Literal with index and overflow 28662.3 Ops/sec
Constructor() with index and overflow 32597.0 Ops/sec
Constructor(times) with index and overflow 24358.1 Ops/sec
Script Preparation code:
x
 
var times = 500;
var noOverflow = 0,
    overflow = 1;
Tests:
  • Literal with push

     
    var arr = [],
        arrSize = times + noOverflow;
    for (var i = 0; i <= arrSize; i++) {
        arr.push(1337);
    }
  • Constructor() with push

     
    var arr = new Array(),
        arrSize = times + noOverflow;
    for (var i = 0; i <= arrSize; i++) {
        arr.push(1337);
    }
  • Constructor(times) with push

     
    var arr = new Array(times),
        arrSize = times + noOverflow;
    for (var i = 0; i <= arrSize; i++) {
        arr.push(1337);
    }
  • Literal with index

     
    var arr = [],
        arrSize = times + noOverflow;
    for (var i = 0; i <= arrSize; i++) {
        arr[i] = 1337;
    }
  • Constructor() with index

     
    var arr = new Array(),
        arrSize = times + noOverflow;
    for (var i = 0; i <= arrSize; i++) {
        arr[i] = 1337;
    }
  • Constructor(times) with index

     
    var arr = new Array(times),
        arrSize = times + noOverflow;
    for (var i = 0; i <= arrSize; i++) {
        arr[i] = 1337;
    }
  • Literal with push and overflow

     
    var arr = [],
        arrSize = times + overflow;
    for (var i = 0; i <= arrSize; i++) {
        arr.push(1337);
    }
  • Constructor() with push and overflow

     
    var arr = new Array(),
        arrSize = times + overflow;
    for (var i = 0; i <= arrSize; i++) {
        arr.push(1337);
    }
  • Constructor(times) with push and overflow

     
    var arr = new Array(times),
        arrSize = times + overflow;
    for (var i = 0; i <= arrSize; i++) {
        arr.push(1337);
    }
  • Literal with index and overflow

     
    var arr = [],
        arrSize = times + overflow;
    for (var i = 0; i <= arrSize; i++) {
        arr[i] = 1337;
    }
  • Constructor() with index and overflow

     
    var arr = new Array(),
        arrSize = times + overflow;
    for (var i = 0; i <= arrSize; i++) {
        arr[i] = 1337;
    }
  • Constructor(times) with index and overflow

     
    var arr = new Array(times),
        arrSize = times + overflow;
    for (var i = 0; i <= arrSize; i++) {
        arr[i] = 1337;
    }