Run details:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0
Firefox 78
Ubuntu
Desktop
4 years ago
Test name Executions per second
Object literal 5108.2 Ops/sec
Constructor 5309.9 Ops/sec
Tests:
  • Object literal

    x
     
    const a = [];
    let i = 0;
    while (i < 10000) {
        const d = {};
        a.push({ b: i });
        i++;
    }
  • Constructor

     
    const a  = [];
    const c = function(i) {
        this.b = i;
    }
    let i = 0;
    while (i < 10000) {
        a.push(new c(i));
        i++;
    }