Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Chrome 133
Mac OS X 10.15.7
Desktop
2 months ago
Test name Executions per second
new EmptyClass 83785304.0 Ops/sec
Object.create(EmptyClass); 76953560.0 Ops/sec
HTML Preparation code:
x
 
1
<script>
2
    // Define the EmptyClass
3
    class EmptyClass {
4
        EmptyClass(a, b) {
5
            this.a = a;
6
            this.b = b;
7
        }
8
    }
9
10
    var resulting = {
11
        instance: null
12
    };
13
</script>
Tests:
  • new EmptyClass

     
    const instance = new EmptyClass(1,2);
    resulting.instance = instance;
  • Object.create(EmptyClass);

     
    const instance = Object.create(EmptyClass);
    instance.a = 1;
    instance.b = 2;
    resulting.instance = instance;