Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
for w/length constant 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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Browser:
Chrome 120
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
some
4.0M/s
foreach with operation
4.0M/s
for
272K/s
for..of
232K/s
View exact numbers
Test name
Executions per second
✓
some
4,029,023 Ops/sec
foreach with operation
3,985,942 Ops/sec
for
271,571 Ops/sec
for..of
231,854 Ops/sec
Script Preparation code:
var array = new Array(100);
Tests:
for
const length = array.length for (var i = 0; i < length; i++) { array[i]; }
foreach with operation
array.forEach(function(i) { array[i]; });
some
array.some(function(i) { array[i]; });
for..of
for (var i of array) { array[i]; }