JSFiddle - React, Tailwind, and code Playground
JavaScript
// Namespace all my code
var bab = new function() {
// Declare cat object
function cat()
{
this.eyes = 2;
this.legs = 4;
this.diet = 'carnivore';
return true;
}
// Declare lion object
function lion()
{
this.mane = true;
this.origin = 'Africa';
this.diet = 'people'; // has priority over cat's diet
return true;
}
// Make lion a subclass of cat
lion.prototype = new cat();
// Create an instance of class lion
var simba = new lion();
// Share diet publicly
this.objInfo = function(name) {
return name; // simba works, name doesn't
};
};
alert(bab.objInfo(window).innerWidth);