Skip to content

Instantly share code, notes, and snippets.

@anurag-majumdar
Created April 16, 2018 12:13
Show Gist options
  • Save anurag-majumdar/3011d9339214dacec4a69c98f2ee3cc7 to your computer and use it in GitHub Desktop.
Save anurag-majumdar/3011d9339214dacec4a69c98f2ee3cc7 to your computer and use it in GitHub Desktop.
// 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