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:
6 months ago
Test name
Executions per second
for
9569023.0 Ops/sec
foreach
6143417.5 Ops/sec
for in
28678212.0 Ops/sec
for..of
741452.9 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; }