Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36
Chrome 86
Mac OS X 10.13.4
Desktop
4 years ago
Test name Executions per second
For Loop for item towards beginning 4027263.2 Ops/sec
While Loop for item towards beginning 4239817.0 Ops/sec
indexOf for item towards beginning 5092348.5 Ops/sec
For Loop for item towards end 4303794.0 Ops/sec
While Loop for item towards end 4277369.0 Ops/sec
indexOf for item towards end 5087058.5 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