Created
December 1, 2018 22:23
-
-
Save manekinekko/3bdb6800daa6b540e36420c05255a7ae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const force = Klass(function Force(name) { | |
this.me = name || 'Force'; | |
this.print = function () { | |
return this.me + ' Force'; | |
}; | |
}); | |
const jedi = Klass(force, function Jedi(name) { | |
this.me = name || 'Jedi'; | |
this.print = function () { | |
return this.me + ' POWA!!'; | |
}; | |
}); | |
const yoda = new jedi('Yoda'); | |
console.log(yoda instanceof jedi); //=> true | |
console.log(yoda instanceof force); //=> true | |
console.log(yoda.print()); //=> Yoda POWA!! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment