Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Map.has vs Object hasOwnProperty vs direct check
(version: 0)
Lookup of map vs object
Comparing performance of:
Map lookup vs Obj lookup vs direct check
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
var map = new Map(); var obj = {}; var j = 0; while (j < 10000) { var key = "Key_" + j; map.set(key, 5); obj[key] = 5; j += 1; } var stringKey = 'asdfasdjfa;sjfjaklfjklsjklajjjj;jlsjfajdfsfjs;fjsfka'; var i = 0, count = 1000, a;
Tests:
Map lookup
for (i = 0; i < count; i++) { a = map.has('stringKey'); }
Obj lookup
for (i = 0; i < count; i++) { a = obj.hasOwnProperty('stringKey'); }
direct check
a = obj['stringKey'] != null
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Map lookup
Obj lookup
direct check
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Comments
Confirm delete:
Do you really want to delete benchmark?