Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:137.0) Gecko/20100101 Firefox/137.0
Firefox 137
Windows
Desktop
one month ago
Test name Executions per second
instanceof 166165632.0 Ops/sec
string type 1828309760.0 Ops/sec
string type + undefined 1825063808.0 Ops/sec
property 1749559296.0 Ops/sec
HTML Preparation code:
AخA
 
1
<script>
2
class TestClass {
3
    constructor() {
4
        this.a = 2;
5
        this.t = 'mesh';
6
    }
7
}
8
</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