JSFiddle - React, Tailwind, and code Playground
by danShumway
JavaScript
//Cats have a speak function.
function Cat(){
this.mySound = "meow";
this.speak = function() {
alert("The cat says: " + this.mySound);
}
}
//Dogs have a speak function.
function Dog(){
this.mySound = "woof";
this.speak = function() {
alert("The dog says: " + this.mySound);
}
}
//Make a cat and a dog.
var myCat = new Cat();
var myDog = new Dog();
//The cat says meow.
myCat.speak();
//The cat says woof.
myCat.speak.call(myDog);