Tests:
  • Array constructor - 10 items

    x
     
    var n = 10;
    var arr = new Array(n);
    for (var i = 0; i < n; i++) {
      arr[i] = i;
    }
  • Array literal - 10 items

     
    var n = 10;
    var arr = [];
    for (var i = 0; i < n; i++) {
      arr.push(i);
    } 
  • Array literal (assign by index) - 10 items

     
    var n = 10;
    var arr = [];
    for (var i = 0; i < n; i++) {
      arr[i] = i;
    } 
  • Array literal (explicit length) - 10 items

     
    var n = 10;
    var arr = [];
    arr.length = n;
    for (var i = 0; i < n; i++) {
      arr[i] = i;
    } 
  • Array constructor - 1000 items

     
    var n = 1000;
    var arr = new Array(n);
    for (var i = 0; i < n; i++) {
      arr[i] = i;
    }
  • Array literal - 1000 items

     
    var n = 1000;
    var arr = [];
    for (var i = 0; i < n; i++) {
      arr.push(i);
    } 
  • Array literal (assign by index) - 1000 items

     
    var n = 1000;
    var arr = [];
    for (var i = 0; i < n; i++) {
      arr[i] = i;
    } 
  • Array literal (explicit length) - 1000 items

     
    var n = 1000;
    var arr = [];
    arr.length = n;
    for (var i = 0; i < n; i++) {
      arr[i] = i;
    } 
  • Array constructor - 100000 items

     
    var n = 100000;
    var arr = new Array(n);
    for (var i = 0; i < n; i++) {
      arr[i] = i;
    }
  • Array literal - 100000 items

     
    var n = 100000;
    var arr = [];
    for (var i = 0; i < n; i++) {
      arr.push(i);
    } 
  • Array literal (assign by index) - 100000 items

     
    var n = 100000;
    var arr = [];
    for (var i = 0; i < n; i++) {
      arr[i] = i;
    } 
  • Array literal (explicit length) - 100000 items

     
    var n = 100000;
    var arr = [];
    arr.length = n;
    for (var i = 0; i < n; i++) {
      arr[i] = i;
    } 
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Array constructor - 10 items
    Array literal - 10 items
    Array literal (assign by index) - 10 items
    Array literal (explicit length) - 10 items
    Array constructor - 1000 items
    Array literal - 1000 items
    Array literal (assign by index) - 1000 items
    Array literal (explicit length) - 1000 items
    Array constructor - 100000 items
    Array literal - 100000 items
    Array literal (assign by index) - 100000 items
    Array literal (explicit length) - 100000 items

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 4 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36
Chrome 85 on Mac OS X 10.15.6
View result in a separate tab
Test name Executions per second
Array constructor - 10 items 5364987.5 Ops/sec
Array literal - 10 items 28669618.0 Ops/sec
Array literal (assign by index) - 10 items 28688986.0 Ops/sec
Array literal (explicit length) - 10 items 7094729.5 Ops/sec
Array constructor - 1000 items 869656.9 Ops/sec
Array literal - 1000 items 254121.5 Ops/sec
Array literal (assign by index) - 1000 items 280799.5 Ops/sec
Array literal (explicit length) - 1000 items 848051.4 Ops/sec
Array constructor - 100000 items 5090.6 Ops/sec
Array literal - 100000 items 1591.1 Ops/sec
Array literal (assign by index) - 100000 items 1679.7 Ops/sec
Array literal (explicit length) - 100000 items 5251.0 Ops/sec