Created
November 8, 2018 09:27
-
-
Save thatkookooguy/a1d0ac1402c95198ca570fe5cfde6f54 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
function canEat(obj) { | |
obj.eat = eat; | |
obj.energy = 0; | |
function eat(energy) { | |
if (!this) { return; } | |
this.energy = this.energy || 0; | |
this.energy += energy; | |
return this.energy; | |
} | |
} | |
class Rabbit { | |
constructor(name) { | |
this.name = name; | |
} | |
} | |
let phillip = new Rabbit('phillip'); | |
console.log(phillip.name); // 'phillip' | |
console.log(phillip.eat); // undefined | |
phillip.eat = eat; | |
console.log(phillip.eat) // undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment