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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Browser:
Chrome 130
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Array.forEach
66.6 Ops/sec
Object.keys().forEach
64.2 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]))