JSFiddle - React, Tailwind, and code Playground

JavaScript

var bar = function bar(str) {
    this.str = str;    
};

bar.prototype = {
    alertTest :  function(additional){
         alert(this.str + ' ' + additional);
    }
};

function foo(str) {
    return new bar(str);
}

foo('hello').alertTest('world');