JSFiddle - React, Tailwind, and code Playground

by rsmclaug

JavaScript

var PageClosure = (function() {
    var privateVariable = "some value";
     
    var privateMethod = function ( ) {
        document.write("private method", "<br/>");
    };
 
    return {
        getPrivateVariable: function() {
            return privateVariable;
        },
        runPrivateMethod: function() {
            privateMethod();
        },
        privateMethodReference: privateMethod
    }
})();
    
PageClosure.privateMethodReference();
PageClosure.runPrivateMethod();
document.write(PageClosure.getPrivateVariable(), "<br/>");
document.write(PageClosure.getPrivateVariable, "<br/>");    
document.write(PageClosure.privateVariable, "<br/>");