Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
foreach vs for..of
Compare loop performance
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0
Browser:
Firefox 115
Operating system:
Windows 7
Device Platform:
Desktop
Date tested:
3 months ago
for..of
83K/s
foreach
76K/s
View exact numbers
Test name
Executions per second
✓
for..of
82,815 Ops/sec
foreach
76,224 Ops/sec
Script Preparation code:
var array = new Array(1000).fill(1);
Tests:
foreach
array.forEach(function(i) { array[i]; });
for..of
for (var i of array) { array[i]; }