Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
For loop vs <Array>.forEach() vs for...of loop
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:134.0) Gecko/20100101 Firefox/134.0
Browser:
Firefox 134
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Benchmark engine:
Benchmark.js
For loop
108.5M/s
<Array>.forEach()
77.5M/s
For...of loop
22.3M/s
View exact numbers
Test name
Executions per second
✓
For loop
108,475,784 Ops/sec
<Array>.forEach()
77,522,920 Ops/sec
For...of loop
22,301,458 Ops/sec
Script Preparation code:
var array = Array(50000, (_, i) => i + 1);
Tests:
<Array>.forEach()
array.forEach(v => v);
For loop
for (let i = 0; i < array.length; i++) array[i];
For...of loop
for (let v of array) v;