Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
for vs foreach vs for..in vs for..of jul 2025
Compare loop performance
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Gecko/20100101 Firefox/145.0
Browser:
Firefox 145
Operating system:
Linux
Device Platform:
Desktop
Date tested:
8 months ago
for in
81.8M/s
foreach
1.2M/s
for
1.0M/s
for..of
323K/s
View exact numbers
Test name
Executions per second
✓
for in
81,804,104 Ops/sec
foreach
1,242,460 Ops/sec
for
1,016,332 Ops/sec
for..of
323,251 Ops/sec
Script Preparation code:
var array = new Array(1000);
Tests:
for
for (var i = 0; i < array.length; i++) { var x = array[i]; }
foreach
array.forEach((el)=> { var e = el; });
for in
for (var el in array) { var e = el; }
for..of
for (var el of array) { var e = el; }