JSFiddle - React, Tailwind, and code Playground
by henser
JavaScript
function Animal(){
this.name="name";
this.spec="species";
this.breed="breed";
this.color="color";
}
Animal.prototype.sayHello = function(){
var msg='Hi! I\'m a '+this.breed+' '+this.spec+' named '+this.name+'!';
return (function(){
alert(msg);
})();
}
function Dog(){
Animal.call(this);
}
function Cat(){
Animal.call(this);
}
Dog.prototype = Object.create(Animal.prototype);
Cat.prototype = Object.create(Animal.prototype);
var bobby = new Dog();
var garfield = new Cat();
bobby.name="Bobby";
bobby.spec="dog";
bobby.color="brown";
bobby.breed="Yorkshire Terrier";
garfield.name="Garfield";
garfield.spec="cat";
garfield.color="golden";
garfield.breed="exotic shorthair";
bobby.sayHello();
garfield.sayHello();