JSFiddle - React, Tailwind, and code Playground

JavaScript

App = window.App || {};
App.SubClass = function(protectedState){

    return {
        logProtectedVar : function(){
            //can access protectedState of parent                 
            alert(protectedState.protectedVar);
            console.log(protectedState.protectedVar);
        }
    }
}// I require protected state to work


//in a seperate file, included second
App = window.App || {}; 
App.ParentClass = (function(){

   var protectedState = {
      protectedVar: 'wow such protection'
   }

   return{
      SubClassInstance: App.SubClass(protectedState), //make the subclass accessible from outside
   }
})(); //closure gives us privacy


App.ParentClass.SubClassInstance.logProtectedVar();