Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// ES6 style
class Gorilla extends Animal {
constructor(name, weight) {
super(name, weight);
}
showVigour() {
return `${super.eat()} ${this.poundChest()}`;
}
dailyRoutine() {
return `${super.wakeUp()} ${this.poundChest()} ${super.eat()} ${super.sleep()}`;
}
// ...
}
// Traditional style
function Gorilla(name, weight) {
Animal.call(this, name, weight);
}
Gorilla.prototype = Object.create(Animal.prototype);
Gorilla.prototype.constructor = Gorilla;
Gorilla.prototype.showVigour = function () {
return `${Animal.prototype.eat.call(this)} ${this.poundChest()}`;
}
Gorilla.prototype.dailyRoutine = function() {
return `${Animal.prototype.wakeUp.call(this)} ${this.poundChest()} ${Animal.prototype.eat.call(this)} ${Animal.prototype.sleep.call(this)}`;
}
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment