Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36 Edg/97.0.1072.55
Chrome 97
Windows
Desktop
2 years ago
Test name Executions per second
For Loop for item towards beginning 3936638.2 Ops/sec
While Loop for item towards beginning 3998805.2 Ops/sec
indexOf for item towards beginning 4145277.5 Ops/sec
For Loop for item towards end 3539521.2 Ops/sec
While Loop for item towards end 3540906.5 Ops/sec
indexOf for item towards end 4136582.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