Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
random Object.hasOwnProperty vs Object in vs Object[] vs Array.indexOf vs Array.includes vs Set.has
(version: 0)
Comparing performance of:
Object.hasOwnProperty vs Object in vs Array.indexOf vs direct vs Array includes vs Set has
Created:
4 years ago
by:
Registered User
Jump to the latest result
Script Preparation code:
var object = {}, array = [], set = new Set(); let i; for (i = 0; i < 1000; i++) { object['something' + i] = true; array.push('something' + i); set.add('something' + i); }
Tests:
Object.hasOwnProperty
object.hasOwnProperty('something' + Math.floor(Math.random() * 1000))
Object in
('something' + Math.floor(Math.random() * 1000)) in object
Array.indexOf
array.indexOf('something' + Math.floor(Math.random() * 1000)) !== -1
direct
object['something' + Math.floor(Math.random() * 1000)]
Array includes
array.includes('something' + Math.floor(Math.random() * 1000))
Set has
set.has('something' + Math.floor(Math.random() * 1000))
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (6)
Previous results
Fork
Test case name
Result
Object.hasOwnProperty
Object in
Array.indexOf
direct
Array includes
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!
Related benchmarks:
Object.prototype.hasOwnProperty vs Object in vs Object[] vs Array.indexOf vs Array.includes vs Set.has
set.add vs. array.push
set.has vs. array.includes (1 million entries)
Array push or set
Comments
Confirm delete:
Do you really want to delete benchmark?