array dynamic length vs array set length

Edit on GitHub

Setup

Tests

  • array dynamic length

    var arr = [];
    for (var i = 0; i < 100000; i++) {
        arr.unshift(i);
    }
  • array set length

    var arr = new Array(100000);
    for (var i = 0; i < 100000; i++) {
        arr.unshift(i);
    }