JSFiddle - React, Tailwind, and code Playground

JavaScript

// Namespace all my code
var bab = new function() {    
    var cat = function() // Declare cat object
    {
      var protected = {}; // Protected vars & methods
      protected.eyes = 2;
      protected.legs = 4;
      protected.diet = 'carnivore';
      return protected; // Pass protected to descendants
    }
    var lion = function()
    {     
      var protected = cat();  // Make lion a subclass of cat        
      var public = {}; // Public vars & methods
      public.legs = protected.legs; // Make 1 protected var public
      public.mane = true;
      public.origin = 'Africa';
      public.diet = 'people'; // has priority over cat's diet
      return public; // Make public vars available
    }    
    var simba = lion();     // Create an instance of class lion
    simba.diet = "Asparagus"; // Change simba, but not lion
    // Get property of choice
    this.objInfo = function(property) {
        return ("Simba: " + simba[property] +
                " - Lion (this is usually private. Shown for testing.): " +
                lion()[property]);
    };
};
alert(bab.objInfo("diet"));