Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
for vs foreach vs some vs for..of
Compare loop performance
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:138.0) Gecko/20100101 Firefox/138.0
Browser:
Firefox 138
Operating system:
Ubuntu
Device Platform:
Desktop
Date tested:
one year ago
for
23.6M/s
some
15.9M/s
foreach
10.5M/s
for..of
1.9M/s
View exact numbers
Test name
Executions per second
✓
for
23,643,284 Ops/sec
some
15,871,896 Ops/sec
foreach
10,453,186 Ops/sec
for..of
1,893,055 Ops/sec
Script Preparation code:
var array = new Array(100);
Tests:
for
for (var i = 0; i < array.length; i++) { array[i]; }
foreach
array.forEach(function(i) { array[i]; });
some
array.some(function(i) { array[i]; });
for..of
for (var i of array) { array[i]; }