Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
Object.prototype.hasOwnProperty vs Object in vs Object[] vs Array.indexOf vs Array.includes vs Set.has
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36
Browser:
Chrome 144
Operating system:
Linux
Device Platform:
Desktop
Date tested:
6 months ago
Benchmark engine:
Benchmark.js
Set has
155.4M/s
Object in
65.1M/s
Object.prototype.hasOwnProperty
48.8M/s
direct
40.4M/s
Array.indexOf
1.3M/s
Array includes
1.3M/s
View exact numbers
Test name
Executions per second
✓
Set has
155,371,760 Ops/sec
Object in
65,136,064 Ops/sec
Object.prototype.hasOwnProperty
48,838,164 Ops/sec
direct
40,359,388 Ops/sec
Array.indexOf
1,324,054 Ops/sec
Array includes
1,311,499 Ops/sec
Script Preparation code:
var object = {}, array = [], set = new Set(), i, test = 1000; for (i = 0; i < 1000; i++) { object['something' + i] = true; array.push('something' + i); set.add('something' + i); }
Tests:
Object.prototype.hasOwnProperty
Object.prototype.hasOwnProperty.call(object, 'something' + test)
Object in
('something' + test) in object
Array.indexOf
array.indexOf('something' + test) !== -1
direct
object['something' + test] === true
Array includes
array.includes('something' + test)
Set has
set.has('something' + test)