Run details:
Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/117.0
Firefox 117
Linux
Desktop
3 months ago
Test name Executions per second
new Array() 1778515328.0 Ops/sec
Array.from() 903696.9 Ops/sec
[] + length 91637984.0 Ops/sec
[] + fill undefined 107701344.0 Ops/sec
[] + fill void 132005272.0 Ops/sec
new Array() zeroed 93331232.0 Ops/sec
Array.from zeroes 818759.8 Ops/sec
[] + fill zeroes 131934096.0 Ops/sec
Tests:
  • new Array()

    AخA
     
    new Array(500)
  • Array.from()

     
    Array.from({ length: 500 })
  • [] + length

     
    let a = [];
    a.length = 500;
  • [] + fill undefined

     
    [].fill(undefined, 0, 500)
  • [] + fill void

     
    [].fill(void 0, 0, 500)
  • new Array() zeroed

     
    new Array().fill(0, 0, 500)
  • Array.from zeroes

     
    Array.from({ length: 500 }, () => 0)
  • [] + fill zeroes

     
    [].fill(0, 0, 500)