Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
for vs for ... of vs forEach vs map
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/141.0.0.0 Safari/537.36
Browser:
Chrome 141
Operating system:
Windows
Device Platform:
Desktop
Date tested:
6 months ago
Test name
Executions per second
for
960701.4 Ops/sec
for ... of
3547609.0 Ops/sec
forEach
3444097.8 Ops/sec
map
3361861.0 Ops/sec
Script Preparation code:
const array = Array.from({ length: 100 }, (_, i) => i) const result = []
Tests:
for
const result = [] for (let i = 0; i < array.length; i++) { result.push(array[i] * 2) }
for ... of
const result = [] for (const value of array) { result.push(value * 2) }
forEach
const result = [] array.forEach((value) => { result.push(value * 2) })
map
const result = array.map((value) => value * 2)