Run details:
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.108 Safari/537.36
Chrome 63
Windows 7
Other
2025 years ago
Test name Executions per second
For loop, basic 2845.7 Ops/sec
While loop, basic 2817.2 Ops/sec
For loop, cached (inside for statement) 4344.5 Ops/sec
For loop, cached (outside for statement) 4367.3 Ops/sec
For loop, i-- (caching inside for loop) 4032.6 Ops/sec
For loop, i-- (caching outside for loop) 4413.7 Ops/sec
While loop, cached 4312.7 Ops/sec
While loop, i-- 4303.8 Ops/sec
forEach 8563.0 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