Tests:
  • Array.from() only

    AخA
     
    Array.from({ length: 100 }, (_, i) => i+i);
  • Array.from().map()

     
    Array.from({ length: 100 }).map((_, i) => i+i);
  • .fill("").map()

     
    Array(100).fill("").map((_, i) => i+i);
  • .fill(null).map()

     
    Array(100).fill(null).map((_, i) => i+i);
  • .fill(undefined).map()

     
    Array(100).fill(null).map((_, i) => i+i);
  • .fill(true).map()

     
    Array(100).fill(true).map((_, i) => i+i);
  • .fill(0).map()

     
    Array(100).fill(0).map((_, i) => i+i);
  • For loop

    x
     
    const a = new Array(100)
    for(let i = 0; i < a.lenght; i++)
      a[i] = i+i
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Array.from() only
    Array.from().map()
    .fill("").map()
    .fill(null).map()
    .fill(undefined).map()
    .fill(true).map()
    .fill(0).map()
    For loop

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Chrome 120 on Windows
View result in a separate tab
Test name Executions per second
Array.from() only 120050.1 Ops/sec
Array.from().map() 126393.0 Ops/sec
.fill("").map() 1114921.9 Ops/sec
.fill(null).map() 1074070.9 Ops/sec
.fill(undefined).map() 1114301.0 Ops/sec
.fill(true).map() 1127919.9 Ops/sec
.fill(0).map() 1174946.9 Ops/sec
For loop 3496883.0 Ops/sec