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:141.0) Gecko/20100101 Firefox/141.0
Browser:
Firefox 141
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
for in
34.5M/s
for
683K/s
foreach
661K/s
for..of
133K/s
View exact numbers
Test name
Executions per second
✓
for in
34,468,448 Ops/sec
for
682,752 Ops/sec
foreach
661,161 Ops/sec
for..of
133,040 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; }