Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:135.0) Gecko/20100101 Firefox/135.0
Firefox 135
Mac OS X 10.15
Desktop
one month ago
Test name Executions per second
new EmptyClass 186718672.0 Ops/sec
Object.create(EmptyClass); 66215348.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;