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 (X11; Linux x86_64; rv:133.0) Gecko/20100101 Firefox/133.0
Browser:
Firefox 133
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Benchmark engine:
Benchmark.js
for..in
43.8M/s
for
1.0M/s
foreach
825K/s
some
819K/s
for..of
108K/s
View exact numbers
Test name
Executions per second
✓
for..in
43,760,372 Ops/sec
for
1,038,414 Ops/sec
foreach
824,732 Ops/sec
some
818,910 Ops/sec
for..of
107,969 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]; }