JSFiddle - React, Tailwind, and code Playground

by johnhoffman

JavaScript

function Animal(sound) {
    this.sound = sound;
}

// wait, i didn't add the makeSound function yet!
console.debug(Animal.prototype);

var dog = new Animal("bark");
var cat = new Animal("meow");
var fish = new Animal("splash");

// write makeSound for the first time
Animal.prototype.makeSound = function() {document.writeln(this.sound);};
cat.makeSound();

// change it up!
Animal.prototype.makeSound = function() {alert(this.sound);};
cat.makeSound();