Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
forEach vs for each vs for of vs for let
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Browser:
Chrome 126
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
array method
26K/s
of
19K/s
in
415/s
traditional
308/s
View exact numbers
Test name
Executions per second
✓
array method
25,759 Ops/sec
of
18,716 Ops/sec
in
415 Ops/sec
traditional
308 Ops/sec
Script Preparation code:
var count = 100000 var arr = Array.from({length: count});
Tests:
traditional
for(let i=0; i<count; i++){ const x = i; }
array method
arr.forEach(r => { const x = i; })
of
for (let each of arr) { const x = each; }
in
for (let each in arr) { const x = each; }