Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
foreach: array vs object keys vs object values vs object entries
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/134.0.0.0 Safari/537.36
Browser:
Chrome 134
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Benchmark engine:
Benchmark.js
array
3.0M/s
object with values
513K/s
object with keys
182K/s
object with entries 1
42K/s
object with entries 2
42K/s
View exact numbers
Test name
Executions per second
✓
array
3,040,054 Ops/sec
object with values
513,191 Ops/sec
object with keys
181,965 Ops/sec
object with entries 1
42,454 Ops/sec
object with entries 2
41,677 Ops/sec
Script Preparation code:
var arr = []; var obj = {}; for (i = 0; i < 1000; ++i) { arr.push(i); obj[i] = i; }
Tests:
array
arr.forEach( (item) => item, );
object with keys
Object.keys(obj).forEach( (key) => key, );
object with values
Object.values(obj).forEach( (value) => value, );
object with entries 1
Object.entries(obj).forEach( (entry) => entry, );
object with entries 2
Object.entries(obj).forEach( ([key, value]) => [key, value], );