Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Instanceof vs constructor.name
(version: 0)
Measure the performance of instanceOf operator vs comparing a basic string type.
Comparing performance of:
instanceof vs property vs constructor comparison
Created:
one year ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script> class TestClass { constructor() { this.a = 2; this.t = 'mesh'; } } </script>
Script Preparation code:
var obj = new TestClass();
Tests:
instanceof
obj instanceof TestClass;
property
obj.constructor.name === "TestClass"
constructor comparison
obj.constructor === TestClass
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
instanceof
property
constructor comparison
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Safari/605.1.15
Browser/OS:
Safari 17 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
instanceof
511920032.0 Ops/sec
property
474105152.0 Ops/sec
constructor comparison
481695520.0 Ops/sec
Related benchmarks:
InstanceOf vs String type
Instanceof vs string comparison vs property checking vs constructor comparison
InstanceOf vs String type 2
InstanceOf vs String type vs Symbol
instanceof vs property in
new class vs function returning obj
InstanceOf vs String type vs Number type
Comments
Confirm delete:
Do you really want to delete benchmark?