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 { | |
constructor(name, weight) { | |
this.name = name; | |
this.weight = weight; | |
} | |
//... | |
} | |
// Check Type of ES6 class |
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
function Animal(name, weight) { | |
this.name = name; | |
this.weight = weight; | |
} | |
Animal.prototype.eat = function() { | |
return `${this.name} is eating!`; | |
} | |
Animal.prototype.sleep = function() { |
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
class Animal { | |
constructor(name, weight) { | |
this.name = name; | |
this.weight = weight; | |
} | |
eat() { | |
return `${this.name} is eating!`; | |
} |
NewerOlder