Skip to content

Instantly share code, notes, and snippets.

@tcare
Last active August 29, 2015 14:11
Show Gist options
  • Save tcare/7b3da77641a7deff19c5 to your computer and use it in GitHub Desktop.
Save tcare/7b3da77641a7deff19c5 to your computer and use it in GitHub Desktop.
ES6 code, with classes
/* ES6 code, with classes */
class Civilian {
constructor(name) {
this.name = name;
}
danger() {
console.log("Run away!");
}
};
class SuperHero extends Civilian {
constructor(name, ability) {
super(name); // Call the super class constructor
this.ability = ability;
}
danger() { // Override the super class method
console.log("Never fear, " + this.name + " is here!");
console.log(this.name + " uses " + this.ability + ". It's super effective.");
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment