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) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Browser:
Chrome 142
Operating system:
Windows
Device Platform:
Desktop
Date tested:
9 months ago
Benchmark engine:
Benchmark.js
<Array>.forEach()
52.9M/s
For loop
38.7M/s
For...of loop
11.5M/s
View exact numbers
Test name
Executions per second
✓
<Array>.forEach()
52,903,912 Ops/sec
For loop
38,725,804 Ops/sec
For...of loop
11,485,117 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;