Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36
Chrome 100
Mac OS X 10.15.7
Desktop
2 years ago
Test name Executions per second
Simple for loop 7770.4 Ops/sec
Simple for loop (reverse) 7577.1 Ops/sec
Array.forEach 69887.6 Ops/sec
for loop + Array.entries 12582.6 Ops/sec
while + Array.entries 12574.5 Ops/sec
enumerable for loop (order not important) 6758.0 Ops/sec
enumerable for loop (order is respected) 2973.3 Ops/sec
Array.map 46384.5 Ops/sec
Array.filter 40023.3 Ops/sec
while + Array.entries (condensed) 13578.0 Ops/sec
for loop + Array.entries (condensed) 13528.0 Ops/sec
Simple for loop (condensed) 7776.2 Ops/sec
Instructionless for loop 7727.1 Ops/sec
Script Preparation code:
Tests:
  • Simple for loop

  • Simple for loop (reverse)

  • Array.forEach

  • for loop + Array.entries

  • while + Array.entries

  • enumerable for loop (order not important)

  • enumerable for loop (order is respected)

  • Array.map

  • Array.filter

  • while + Array.entries (condensed)

  • for loop + Array.entries (condensed)

  • Simple for loop (condensed)

  • Instructionless for loop