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 (X11; Linux x86_64; rv:133.0) Gecko/20100101 Firefox/133.0
Browser:
Firefox 133
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Object.keys().forEach
18/s
Array.forEach
17/s
View exact numbers
Test name
Executions per second
✓
Object.keys().forEach
18 Ops/sec
Array.forEach
17 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]))