Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
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 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
Browser:
Chrome 129
Operating system:
Chrome OS 14541.0.0
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
array
1264109.9 Ops/sec
object with keys
43271.4 Ops/sec
object with values
176383.7 Ops/sec
object with entries 1
11310.9 Ops/sec
object with entries 2
10696.6 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], );