Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
for vs foreach vs for..in vs for..of (Fixed)
Compare loop performance
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Mobile Safari/537.36
Browser:
Chrome Mobile 140
Operating system:
Android
Device Platform:
Mobile
Date tested:
10 months ago
for..of
20.9M/s
for
6.1M/s
for in
5.2M/s
foreach
4.7M/s
View exact numbers
Test name
Executions per second
✓
for..of
20,879,148 Ops/sec
for
6,147,948 Ops/sec
for in
5,158,672 Ops/sec
foreach
4,665,900 Ops/sec
Script Preparation code:
var array = new Array(100);
Tests:
for
for (let i = 0, len = array.length; i < len; i++) { array[i]; }
foreach
array.forEach(function(i) { i; });
for in
for (let i in array) { array[i]; }
for..of
for (let i of array) { i; }