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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Browser:
Chrome 131
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Benchmark engine:
Benchmark.js
For...of loop
14.9M/s
<Array>.forEach()
14.7M/s
For loop
3.2M/s
View exact numbers
Test name
Executions per second
✓
For...of loop
14,865,479 Ops/sec
<Array>.forEach()
14,683,325 Ops/sec
For loop
3,165,138 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;