Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
typeof vs instanceof vs constructor equality check
(version: 1)
Comparing typeof vs instanceof vs .constructor property
Comparing performance of:
instanceof check vs constructor check
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
function Ticket(id) { this._id = id; } var testTicket = new Ticket(1); var count = 1000;
Tests:
instanceof check
for (var i = 0; i < count; i += 1) { if (testTicket instanceof Ticket) { continue; } }
constructor check
for (var i = 0; i < count; i += 1) { if (testTicket.constructor === Ticket) { continue; } }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
instanceof check
constructor check
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
8 months ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:142.0) Gecko/20100101 Firefox/142.0
Browser/OS:
Firefox 142 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
instanceof check
139153.1 Ops/sec
constructor check
2111760.2 Ops/sec
Related benchmarks:
className.indexOf vs. classList.contains 3
Instanceof vs string comparison vs property checking vs constructor comparison
set num vs set fnCall vs typecheck then set
typeof vs instanceof vs constructor
className.indexOf vs. classList.contains2
InstanceOf vs flag
instanceof vs constructor comparison
boolean flag vs. classList.contains
new class vs function returning obj
Comments
Confirm delete:
Do you really want to delete benchmark?