Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
For vs for of vs forEach
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Gecko/20100101 Firefox/145.0
Browser:
Firefox 145
Operating system:
Linux
Device Platform:
Desktop
Date tested:
8 months ago
for loop
6K/s
reduce
4K/s
forEach
4K/s
for of
1K/s
View exact numbers
Test name
Executions per second
✓
for loop
5,776 Ops/sec
reduce
4,175 Ops/sec
forEach
4,167 Ops/sec
for of
1,033 Ops/sec
Script Preparation code:
var array = new Array(100000);
Tests:
for loop
let value; for (var i = 0; i < array.length; i++) { value = array[i]; }
forEach
let value; array.forEach(function(i) { value = i; });
for of
let value; for (var i of array) { value = i; }
reduce
const value = array.reduce((prev, current) => current, null)