Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Object.hasOwnProperty vs Object in vs Object[] vs Array.indexOf vs Array.find vs Map.has
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:123.0) Gecko/20100101 Firefox/123.0
Browser:
Firefox 123
Operating system:
Linux
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Object.hasOwnProperty
945507648.0 Ops/sec
Object in
891083392.0 Ops/sec
Array.indexOf
8324755.5 Ops/sec
direct
941446272.0 Ops/sec
Array find
45489.6 Ops/sec
Map has
790937088.0 Ops/sec
Script Preparation code:
var object = {}, array = [], i, test = 1000; var map = new Map(); for (i = 0; i < 1000; i++) { object['something' + i] = true; array.push({id: 'something' + i}); map.set('something' + i, true); }
Tests:
Object.hasOwnProperty
object.hasOwnProperty('something' + test)
Object in
('something' + test) in object
Array.indexOf
array.indexOf({id:'something' + test}) !== -1
direct
object['something' + test] === true
Array find
array.find(e => e.id === 'something' + test)
Map has
map.has('something' + test)