Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array.forEach vs Object.keys().forEach
If I have an array, is it faster to use Array.forEach or Object.keys().forEach?
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Mobile Safari/537.36
Browser:
Chrome Mobile 130
Operating system:
Android
Device Platform:
Mobile
Date tested:
one year ago
Test name
Executions per second
Array.forEach
6.1 Ops/sec
Object.keys().forEach
5.9 Ops/sec
Script Preparation code:
var arr = (new Array(10000)).fill(0).map((x, i) => { return i + 1 })
Tests:
Array.forEach
arr.forEach(val => console.log(val))
Object.keys().forEach
Object.keys(arr).forEach(key => console.log(arr[key]))