JSFiddle - React, Tailwind, and code Playground

by dsbonev

JavaScript

/* inheritance playground */

function P() {
    this.name = 'Parent';
}
    
P.prototype.getNameParentPrototype = function () {
    return this.name + ' from getNameParentPrototype';
};
    

P.getNameParentConstructor = function () {
    return this.name + ' from getNameParentConstructor';
};
    
function C() {
    this.name = 'Child';
}

var parent = new P();
console.dir(parent);

C.prototype = parent;
C.prototype.getNameChildPrototype = function () {
    return this.name + ' from getNameChildPrototype';
};
C.getNameChildConstructor = function () {
    return this.name + ' from getNameChildConstructor';
};


var child = new C();
console.dir(child);