Test name | Executions per second |
---|---|
Instanceof | 115332504.0 Ops/sec |
Constructor comparison | 625072000.0 Ops/sec |
<script>
class TestClass {
a = 0;
b = 0;
constructor() {
this.a = 2;
}
get GetA() {
return this.a;
}
GetB() {
return this.b;
}
}
</script>
var obj = new TestClass();
obj instanceof TestClass;
obj.constructor === TestClass;