Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
forEach vs for ... of
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/123.0.0.0 Safari/537.36 OPR/109.0.0.0 (Edition Yx 05)
Browser:
Opera 109
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
for of
16/s
forEach
14/s
View exact numbers
Test name
Executions per second
✓
for of
16 Ops/sec
forEach
14 Ops/sec
Script Preparation code:
function generateTestArray() { const result = []; for (let i = 0; i < 1000000; ++i) { result.push({ a: i, b: i / 2, r: 0, }); } return result; }
Tests:
forEach
const a = generateTestArray(); a.forEach( b => b*2 );
for of
const a = generateTestArray(); for ( let b of a) { b=b*2; }