Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Instanceof vs string comparison vs property checking vs constructor comparison 2
(version: 0)
Measure the performance of instanceOf operator vs comparing a basic string type. but more properties
Comparing performance of:
instanceof vs string type vs string type + undefined vs property vs constructor comparison
Created:
4 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script> class TestClass { constructor() { this.a = 2; this.b = 'hello'; this.c = ['some','thing']; this.d = [1,1,2,3,5,8,13,21]; this.e = 'foofoofoo'; this.f = 'barbarbar'; this.g = {foo:'bar',12:34}; this.h = {nested:{nestedMore:{nestedEvenMore:'nah'}}}; this.t = 'mesh'; } } </script>
Script Preparation code:
var obj = new TestClass();
Tests:
instanceof
obj instanceof TestClass;
string type
obj.t === 'mesh'
string type + undefined
obj.t !== undefined
property
obj.a !== undefined
constructor comparison
obj.constructor === TestClass
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (5)
Previous results
Fork
Test case name
Result
instanceof
string type
string type + undefined
property
constructor comparison
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
instanceof vs typeof vs fast typeof object
instanceof vs typeof for objects
Check object. typeof vs constructor + null check
Check object. typeof vs constructor
instanceof vs typeof franco
Comments
Confirm delete:
Do you really want to delete benchmark?