Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
Fors comparison
for vs for..in vs for..of vs forEach
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/120.0.0.0 Mobile Safari/537.36
Browser:
Chrome Mobile 120
Operating system:
Android
Device Platform:
Mobile
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
for...of
2K/s
forEach
793/s
for
66/s
for.. in
43/s
View exact numbers
Test name
Executions per second
✓
for...of
2,329 Ops/sec
forEach
793 Ops/sec
for
66 Ops/sec
for.. in
43 Ops/sec
Script Preparation code:
var tab = []; for (let i = 0; i < 100000; ++i) { tab.push({ a: i.toString(), b: i }); }
Tests:
for
for(let i = 0; i < 100000; ++i) { tab[i].a = 'aaaaaaaaaaa'; tab[i].b = 0; }
for.. in
for(let index in tab) { tab[index].a = 'bbbbbbbbb'; tab[index].b = 0; }
for...of
for(let obj of tab) { obj.a = 'cccccccccc'; obj.b = 0; }
forEach
tab.forEach((obj) => { obj.a = 'dddddddd'; obj.b = 0; });