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:
19 days ago
Test name
Executions per second
foreach
76223.6 Ops/sec
for..of
82815.5 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]; }