JSFiddle - React, Tailwind, and code Playground

by bittersweetryan

JavaScript

function Mammal(name){
    this.name = name;
}

Mammal.prototype.getName = function(){
       return "My name is " + this.name;
   };

function Cat(name){
    this.name = name;
}

Cat.prototype = new Mammal();


var genericAnimal = new Mammal("Pete");
var cat = new Cat("Bart");

console.log(genericAnimal.getName());

console.log(cat.getName());