Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Set has vs object key (large dataset)
(version: 1)
performance comparison of ways to find if an array contains a value
Comparing performance of:
Includes vs Object[key] vs Set.has
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
var obj = (new Array(100000)).fill(null).reduce((prev, newVal) => {prev[Math.random() + ''] = Math.random() + ''; return prev; }, { sausage: 'tst' }); var array = Object.keys(obj); var set = new Set(array);
Tests:
Includes
if(array.includes('sausage')) console.log("found");
Object[key]
if(obj['sausage']) console.log("found");
Set.has
if(set.has('sausage')) console.log("found");
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Includes
Object[key]
Set.has
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?