JSFiddle - React, Tailwind, and code Playground

HTML

<div id="output"></div>

JavaScript

// how can i access a public method from a private one?
// (in this example publicAlert from privateMethod)
// this refers to the window object.

$(function() {
var modulePattern = (function($)
{
    var $this = this;
    var privateMethod = function()
    {
        appendText("called privateMethod()");
        $this.publicAlert();
    }
        
    var appendText = function(text)
    {
        var text = $('#output').text() + " | " + text;
        $('#output').text(text);
    }
        
    this.publicMethod = function(){
        appendText("called publicMethod()");
        privateMethod();
    };
        
    this.publicAlert = function(){
        alert("publicAlert");
    }
});

mp = new modulePattern($);
mp.publicMethod();
});