Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
loops: 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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Browser:
Chrome 131
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Benchmark engine:
Benchmark.js
for..in
1.1M/s
some
1.0M/s
foreach
1.0M/s
for
519K/s
for..of
103K/s
View exact numbers
Test name
Executions per second
✓
for..in
1,112,456 Ops/sec
some
1,046,928 Ops/sec
foreach
1,044,240 Ops/sec
for
518,529 Ops/sec
for..of
102,548 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]; }