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:
10 months ago
Benchmark engine:
Benchmark.js
Set has
77.5M/s
Object in
36.6M/s
Object.prototype.hasOwnProperty
27.9M/s
direct
20.3M/s
Array.indexOf
632K/s
Array includes
563K/s
View exact numbers
Test name
Executions per second
✓
Set has
77,463,592 Ops/sec
Object in
36,627,856 Ops/sec
Object.prototype.hasOwnProperty
27,886,976 Ops/sec
direct
20,261,460 Ops/sec
Array.indexOf
632,078 Ops/sec
Array includes
562,919 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)