JSFiddle - React, Tailwind, and code Playground

by juristr

HTML

<script src="https://getfirebug.com/firebug-lite-debug.js"></script>

JavaScript

var Animal = function(name){
   this.name = name;            
};

Animal.prototype.makeSound = function(){
    console.log(this.name + ": " + (this.sound || "(bo)"));
};


var Dog = function(name){
  Animal.call(this, name);
  this.sound = "wuff";   
};
Dog.prototype = Animal.prototype;

var Cat = function(name){
  Animal.call(this, name);  
  this.sound = "miao";
};
Cat.prototype = Animal.prototype;



//test
var dolphin = new Animal("Dolphin");
dolphin.makeSound();

var dog = new Dog("Bello");
dog.makeSound();

var cat = new Cat("Mietze");
cat.makeSound();