JSFiddle - React, Tailwind, and code Playground

JavaScript

function myObj(testFunc) {
    this.testFunc = testFunc;
    
    
    this.Foo = function Foo(test) {
        this.test = test;

        this.saySomething = function(text) {
            alert(text);
        };
    };
    
    var Foo = this.Foo;
    
    this.testFunc.apply(this);
}

var test = new myObj(function() {
    with (this) {
        var test = new Foo();
        test.saySomething("Hello world");
    }
});