JSFiddle - React, Tailwind, and code Playground

JavaScript

function EventTarget() {
    this.baz = function() {console.log("baz")};
    this.foobar = "foobar";
}

function MyObject() {
    EventTarget.call(this);
    
    this.foo = function() {console.log("foo")};
    this.bar = function() {console.log("bar")};
}
MyObject.prototype = new EventTarget();
MyObject.prototype.constructor = MyObject;      

thisObject = new MyObject();

thisObject.foo();
thisObject.bar();
thisObject.baz();
console.log(thisObject.foobar);