Object.prototype.hasOwnProperty vs Object in vs Array.indexOf vs direct vs Array includes vs Set hasFastest: Set has (139.5x faster)
153,545,616 ops/sec
65,081,556 ops/sec
42,852,144 ops/sec
31,183,858 ops/sec
1,126,234 ops/sec
1,100,812 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| Object.prototype.hasOwnProperty | |
| Object in | |
| Array.indexOf | |
| direct | |
| Array includes | |
| Set has |
| Test name | Executions per second |
|---|---|
| ✓ Set has | 291,956,992 Ops/sec |
| Object in | 97,524,400 Ops/sec |
| Object.prototype.hasOwnProperty | 76,781,608 Ops/sec |
| direct | 55,451,540 Ops/sec |
| Array includes | 1,553,713 Ops/sec |
| Array.indexOf | 1,536,186 Ops/sec |