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 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0
Browser:
Firefox 128
Operating system:
Linux
Device Platform:
Desktop
Date tested:
8 months ago
Test name
Executions per second
for
1554500.8 Ops/sec
foreach
1698328.1 Ops/sec
for in
4800459.0 Ops/sec
for..of
250050.3 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; }