Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save manekinekko/3bdb6800daa6b540e36420c05255a7ae to your computer and use it in GitHub Desktop.
Save manekinekko/3bdb6800daa6b540e36420c05255a7ae to your computer and use it in GitHub Desktop.
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