Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Object.values on array vs Object
Is it significantly better to do Object.values(<array or object>) or if( Array.isArray(<array or object>) ) { array = <array or object> } else { Object.values(obj) }
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.0
Browser:
Chrome 138
Operating system:
Windows
Device Platform:
Desktop
Date tested:
9 months ago
Test name
Executions per second
a
5649175.5 Ops/sec
o
561100.6 Ops/sec
ac
10675785.0 Ops/sec
oc
569173.8 Ops/sec
Script Preparation code:
var obj = {} for(let i = 0; i < 50; ++i) { let k = String.fromCharCode((i % 26) + 97); obj[k] = i; } var arr = Object.values(obj); var dest = null;
Tests:
a
dest = Object.values(arr);
o
dest = Object.values(obj);
ac
if( Array.isArray(arr) ) { dest = arr; } else { dest = Object.values(arr); }
oc
if( Array.isArray(obj) ) { dest = obj; } else { dest = Object.values(obj); }