Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36 Edg/143.0.0.0
Browser:
Chrome 143
Operating system:
Windows
Device Platform:
Desktop
Date tested:
9 months ago
Benchmark engine:
Benchmark.js
for..of
38.2M/s
foreach
10.7M/s
for
9.6M/s
for in
8.4M/s
View exact numbers
Test name
Executions per second
✓
for..of
38,247,720 Ops/sec
foreach
10,703,602 Ops/sec
for
9,600,012 Ops/sec
for in
8,350,075 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; }