Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
hasOwnProperty vs NO-hasOwnProperty vs object.keys
(version: 1)
Comparing performance of:
hasOwnProperty vs NO-hasOwnProperty vs Object.keys
Created:
one year ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
let obj = { 'a': 1, 'b': 1, 'c': 1, 'd': 1, 'e': 1, 'f': 1, 'g': 1 };
Tests:
hasOwnProperty
let data = ''; for (let i=10000; i >= 0; i--) { for (let key in obj) { if(obj.hasOwnProperty(key)) { data = key; } } }
NO-hasOwnProperty
let data = ''; for (let i=10000; i >= 0; i--) { for (let key in obj) { data = key; } }
Object.keys
let data = ''; for (let i=10000; i >= 0; i--) { Object.keys(obj).forEach(key => { data = key; }); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
hasOwnProperty
NO-hasOwnProperty
Object.keys
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Browser/OS:
Chrome 131 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
hasOwnProperty
1242.6 Ops/sec
NO-hasOwnProperty
13351.5 Ops/sec
Object.keys
4154.0 Ops/sec
Related benchmarks:
js for in vs object.keys
for-in vs object.keys vs object.keys 2
for-in with hasOwnProperty() vs object.keys
for-in with hasOwnProperty checking vs object.keys
for-in vs for-of Object.keys 2
for-in vs for-of object.keys
for-in-hasOwnProperty vs object.keys
for-in-hasOwnProperty vs object.keys-direct
for-in vs object.keys no foreach
Comments
Confirm delete:
Do you really want to delete benchmark?