Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Safari/605.1.15
Safari 18
Mac OS X 10.15.7
Desktop
3 months ago
Test name Executions per second
Simple for loop - Access index and value 37939.8 Ops/sec
Array.forEach - Access index and value 160710.2 Ops/sec
for-of + Array.entries 89407.2 Ops/sec
for-of - Access value only 785694.2 Ops/sec
Simple for loop - Access value only 38076.7 Ops/sec
Array.forEach - Access value only 160964.9 Ops/sec
Script Preparation code:
Tests:
  • Simple for loop - Access index and value

  • Array.forEach - Access index and value

  • for-of + Array.entries

  • for-of - Access value only

  • Simple for loop - Access value only

  • Array.forEach - Access value only


;