Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save manekinekko/780a57634f0393301f718c4b3f8eea0d to your computer and use it in GitHub Desktop.
Save manekinekko/780a57634f0393301f718c4b3f8eea0d to your computer and use it in GitHub Desktop.
class Force {
constructor(name = 'Force'){
this.me = name;
}
print(){
return `${this.me} Force`;
}
}
class Jedi extends Force {
constructor(name = 'Jedi'){
super();
this.me = name;
}
print(){
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