Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Rat(name) {
- this.name = name;
- this.unitedRats = [];
- Object.defineProperties(this, {
- unite: {
- value: (rat) => {
- if (!(rat instanceof Rat)) {
- return;
- }
- this.unitedRats.push(rat);
- },
- enumerable: false,
- },
- getRats: {
- value: () => this.unitedRats,
- enumerable: false,
- },
- toString: {
- value: () => `${this.name}${this.unitedRats.map((r) => `\n##${r.name}`).join('')}`,
- enumerable: false,
- },
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement