Created
August 21, 2023 07:28
-
-
Save zolotyh/83b8efb5e23e1fb722d49770e5ffdab2 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 Hamster() {} | |
Hamster.prototype.food = []; | |
Hamster.prototype.feed = function (item) { | |
this.food.push(item); | |
}; | |
const speedy = new Hamster(); | |
const lazy = new Hamster(); | |
speedy.feed("яблоко"); | |
speedy.feed("лимон"); | |
console.log(speedy.food.length); | |
console.log(lazy.food.length); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment