JSFiddle - React, Tailwind, and code Playground

by badsyntax

HTML

<!-- Click run above to execute the javascript -->

JavaScript

// Our super constructor
function Animal() {
    alert(this.type);    
}

Animal(); // will alert 'undefined';

Animal.call({
    type: 'reptile' 
}); // will alert reptile

// Our sub constructor
function Cat() {
    
    this.type = 'feline';
    
    // execute the super constructor in the context of this constructor
    Animal.call(this); 
}

Cat(); // will alert 'feline'