Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
instanceof vs constructor check vs field
(version: 1)
Comparing performance of:
instanceof vs constructor vs field vs constructor.name
Created:
6 months ago
by:
Registered User
Jump to the latest result
Script Preparation code:
var A = class A { _className = 'A' } var a = new A()
Tests:
instanceof
var b = a instanceof A
constructor
var b = a.constructor === A
field
var b = a._className === 'A'
constructor.name
var b = a.constructor.name === 'A'
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
instanceof
constructor
field
constructor.name
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
6 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36
Browser/OS:
Chrome 141 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
instanceof
160329680.0 Ops/sec
constructor
174615584.0 Ops/sec
field
174174064.0 Ops/sec
constructor.name
54220272.0 Ops/sec
Related benchmarks:
object members
Check Object types
instanceof vs typeof 3
Object.defineProperty vs assignment
instanceof vs check attr
equals
equal vs assign vs defineProperty
instanceof vs constructor.name vs field
fn field vs obj field
Comments
Confirm delete:
Do you really want to delete benchmark?