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/142.0.0.0 Safari/537.36
Browser:
Chrome 142
Operating system:
Linux
Device Platform:
Desktop
Date tested:
9 months ago
Benchmark engine:
Benchmark.js
Set has
173.0M/s
Object in
74.6M/s
Object.prototype.hasOwnProperty
46.7M/s
direct
35.3M/s
Array includes
1.4M/s
Array.indexOf
1.4M/s
View exact numbers
Test name
Executions per second
✓
Set has
173,045,360 Ops/sec
Object in
74,607,768 Ops/sec
Object.prototype.hasOwnProperty
46,698,116 Ops/sec
direct
35,345,020 Ops/sec
Array includes
1,428,514 Ops/sec
Array.indexOf
1,428,242 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)