JSFiddle - React, Tailwind, and code Playground

HTML

<script src="http://cdn.crafty-modules.com/crafty-DEBUG.js"></script>

JavaScript

Crafty.init(100,100);
Crafty.scene("InheritanceExample", function()
{
    Crafty.background("#000");
    //A Crafty component
    Crafty.c('Mammal',
    {
        name: "",  //this is a variable of the component, a property
        size: "",
        toString: function () {  //this is a function of the class, a method
            return "Mammal: "+this.name;
        }
    });
    var myMammal = Crafty.e('Mammal',{});
    myMammal.name = "Mr. Fancypants";
    console.log( ""+myMammal.toString() )
        
    //This does not work:
    //Cat.prototype = Crafty.e('Mammal',{});
       
    //But, we can overwrite the function by applying a different component with the same function/method name
    Crafty.c('Cat',
    {
        toString: function () {
            return "Cat: "+this.name;
        }            
    });
    myMammal.addComponent('Cat',{});
    myMammal.name = "Mr. Meow";
    console.log(  ""+myMammal.toString()  )    
})
Crafty.scene("InheritanceExample");