Test name | Executions per second |
---|---|
instanceof | 191508304.0 Ops/sec |
string type | 167427600.0 Ops/sec |
string type + undefined | 187944224.0 Ops/sec |
property | 180722896.0 Ops/sec |
constructor comparison | 180859728.0 Ops/sec |
<script>
class TestClass {
constructor() {
this.a = 2;
this.t = 'mesh';
}
}
</script>
var obj = new TestClass();
obj instanceof TestClass;
obj.t === 'mesh'
obj.t !== undefined
obj.a !== undefined
obj.constructor === TestClass