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:
curl
Browser:
Other
Operating system:
Other
Device Platform:
Desktop
Date tested:
one year ago
foreach
4.3M/s
some
4.3M/s
for..of
249K/s
for
153K/s
View exact numbers
Test name
Executions per second
✓
foreach
4,346,346 Ops/sec
some
4,304,777 Ops/sec
for..of
248,583 Ops/sec
for
152,529 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]; }