Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Fastest way to find keys in objects
Fastest way to find keys in objects
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:138.0) Gecko/20100101 Firefox/138.0
Browser:
Firefox 138
Operating system:
Ubuntu
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
undefined
13626743.0 Ops/sec
hasOwnProperty
10824985.0 Ops/sec
in
14061618.0 Ops/sec
Script Preparation code:
source = { a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8, }; target = { a: 1, b: 2, d: 4, e: 5, f: 6, i: 9, j: 10, };
Tests:
undefined
for (const sourceKey in source) { if (target[sourceKey] === undefined) { delete target.sourceKey; } }
hasOwnProperty
for (const sourceKey in source) { if (!target.hasOwnProperty(sourceKey)) { delete target.sourceKey; } }
in
for (const sourceKey in source) { if (!(sourceKey in target)) { delete target.sourceKey; } }