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 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0
Browser:
Firefox 128
Operating system:
Windows
Device Platform:
Desktop
Date tested:
7 months ago
Test name
Executions per second
Array.forEach
11.2 Ops/sec
Object.keys().forEach
12.3 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]))