Created
April 16, 2018 12:13
-
-
Save anurag-majumdar/3011d9339214dacec4a69c98f2ee3cc7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Animal { | |
// ... | |
eat() { | |
return `${this.name} is eating!`; | |
} | |
sleep() { | |
return `${this.name} is going to sleep!`; | |
} | |
wakeUp() { | |
return `${this.name} is waking up!`; | |
} | |
// ... | |
} | |
// Traditional style | |
Animal.prototype.eat = function() { | |
return `${this.name} is eating!`; | |
} | |
Animal.prototype.sleep = function() { | |
return `${this.name} is going to sleep!`; | |
} | |
Animal.prototype.wakeUp = function() { | |
return `${this.name} is waking up!`; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment