Run details:
Mozilla/5.0 (iPhone; CPU iPhone OS 15_2_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Mobile/15E148 Safari/604.1
Mobile Safari 15
iOS 15.2.1
Mobile
2 years ago
Test name Executions per second
For Loop for item towards beginning 6977992.5 Ops/sec
While Loop for item towards beginning 5139028.5 Ops/sec
indexOf for item towards beginning 6004311.5 Ops/sec
For Loop for item towards end 5703798.0 Ops/sec
While Loop for item towards end 5619095.0 Ops/sec
indexOf for item towards end 3807457.2 Ops/sec
Script Preparation code:
Tests:
  • For Loop for item towards beginning

  • While Loop for item towards beginning

  • indexOf for item towards beginning

  • For Loop for item towards end

  • While Loop for item towards end

  • indexOf for item towards end