JSFiddle - React, Tailwind, and code Playground

by Slava Fomin II

HTML

<input type="number" id="parent-class-created-count">
<p>Should be 3!</p>

JavaScript

var parentClassCreatedCount = 0;

function Parent() {
    parentClassCreatedCount++;
    
    // Some heavy calculations here and RAM consumption.
    // ...
}

function Child() {
    this.constructor.apply(this, arguments);
}
Child.prototype.constructor = Parent;

var a = new Parent();
var b = new Child();
var c = new Child();

document.getElementById('parent-class-created-count').value = parentClassCreatedCount;