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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 Edg/144.0.0.0
Browser:
Chrome 144
Operating system:
Windows
Device Platform:
Desktop
Date tested:
7 months ago
Benchmark engine:
Benchmark.js
direct
11.4M/s
Object in
9.7M/s
Object.prototype.hasOwnProperty
8.9M/s
Set has
6.8M/s
Array includes
872K/s
Array.indexOf
870K/s
View exact numbers
Test name
Executions per second
✓
direct
11,409,028 Ops/sec
Object in
9,662,752 Ops/sec
Object.prototype.hasOwnProperty
8,946,884 Ops/sec
Set has
6,763,796 Ops/sec
Array includes
872,249 Ops/sec
Array.indexOf
870,426 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)