Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
for vs foreach vs some vs for..of vs for in
Compare loop performance
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:129.0) Gecko/20100101 Firefox/129.0
Browser:
Firefox 129
Operating system:
Ubuntu
Device Platform:
Desktop
Date tested:
one year ago
for in
68.6M/s
foreach
828K/s
some
775K/s
for
567K/s
for..of
101K/s
View exact numbers
Test name
Executions per second
✓
for in
68,559,840 Ops/sec
foreach
828,150 Ops/sec
some
775,247 Ops/sec
for
567,377 Ops/sec
for..of
100,980 Ops/sec
Script Preparation code:
var array = new Array(1000);
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]; }
for in
for (var i in array) { array[i]; }