Test name | Executions per second |
---|---|
instanceof | 39507116.0 Ops/sec |
string type | 86508840.0 Ops/sec |
string type + undefined | 34966680.0 Ops/sec |
property | 33149456.0 Ops/sec |
constructor comparison | 40121508.0 Ops/sec |
<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>
var obj = new TestClass();
obj instanceof TestClass;
obj.t === 'mesh'
obj.t !== undefined
obj.a !== undefined
obj.constructor === TestClass