JSFiddle - React, Tailwind, and code Playground

JavaScript

function Parent(){}
Parent.prototype.do = function(){ 
    var name = this.constructor.toString().match(/function ([^(]+)/)[1];
    console.log(name);
}

function Child1(){}
Child1.prototype = new Parent();
Child1.prototype.constructor = Child1;

function Child2(){}
Child2.prototype = new Parent();
Child2.prototype.constructor = Child2;

new Child1().do(); // logs Child1
new Child2().do(); // logs Child2