JSFiddle - React, Tailwind, and code Playground

by louisbros

JavaScript

var New = Object.create;

function Actor() {}

// Player > Actor
function Player() {}
Player.prototype = New(Actor.prototype);

// Monster > Actor
function Monster() {}
Monster.prototype = New(Actor.prototype);

// Dwarf > Player > Actor
function Dwarf() {}
Dwarf.prototype = New(Player.prototype);

// Angel > Monster > Actor
function Angel() {}
Angel.prototype = New(Monster.prototype);

// create the instance
var angel = new Angel();

console.log(angel instanceof Player); // false
console.log(angel instanceof Monster); // true
console.log(angel instanceof Actor); // true