Last active
April 16, 2018 13:59
-
-
Save anurag-majumdar/211a6a2da55ff5ca6880cf90d4dc30e7 to your computer and use it in GitHub Desktop.
This file contains 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
// 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