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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
Browser:
Chrome 137
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
10 months ago
Test name
Executions per second
for loop
4895.2 Ops/sec
forEach
5679.6 Ops/sec
for of
10727.2 Ops/sec
reduce
5219.3 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)