Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36
Chrome 64
Windows
Other
2025 years ago
Test name Executions per second
For loop, basic 1792.4 Ops/sec
While loop, basic 1868.5 Ops/sec
For loop, cached (inside for statement) 2771.5 Ops/sec
For loop, cached (outside for statement) 2846.3 Ops/sec
For loop, i-- (caching inside for loop) 2884.0 Ops/sec
For loop, i-- (caching outside for loop) 2297.7 Ops/sec
While loop, cached 2607.3 Ops/sec
While loop, i-- 2628.4 Ops/sec
forEach 6036.7 Ops/sec
Script Preparation code:
Tests:
  • For loop, basic

  • While loop, basic

  • For loop, cached (inside for statement)

  • For loop, cached (outside for statement)

  • For loop, i-- (caching inside for loop)

  • For loop, i-- (caching outside for loop)

  • While loop, cached

  • While loop, i--

  • forEach