JSFiddle - React, Tailwind, and code Playground

JavaScript

function Parent(name) {
    // Private variables here
    var myName;
    
    // Constructor
    myName = name;

    // Public interface
    return {
        func1: function () {alert("Parent func1. Name: " + myName); },
        func2: function () {alert("Parent func2. Name: " + myName); }
    }
}

function Child(name) {
    // Private variables here
    var myName,
        exportObj;
    
    // Constructor
    // Inherit
    exportObj = Parent(name + "'s father");

    // Override
    exportObj.func2 = function () {
        alert("Child func2. Name: " + name);
    }

    // Export public interface
    return exportObj;
}

var child = Child("John");
child.func1();
child.func2();