1 A dead simple way to do inheritance in JS.
3 var inherits = require("inherits")
8 Animal.prototype.say = function (what) {
16 Dog.prototype.sniff = function () {
17 this.say("sniff sniff")
19 Dog.prototype.bark = function () {
23 inherits(Chihuahua, Dog)
24 function Chihuahua () {
25 Chihuahua.super.apply(this)
27 Chihuahua.prototype.bark = function () {
35 Cat.prototype.hiss = function () {
38 inherits(Cat, Animal, {
39 meow: function () { this.say("miao miao") }
41 Cat.prototype.purr = function () {
47 assert(c instanceof Chihuahua)
48 assert(c instanceof Dog)
49 assert(c instanceof Animal)
51 The actual function is laughably small. 10-lines small.