Last active
July 3, 2024 01:28
-
-
Save Takazudo/92b9c1bdc1a6d968838d to your computer and use it in GitHub Desktop.
Cat
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 Cat { | |
constructor(name) { | |
this.name = name; | |
} | |
set name(name) { | |
this._name = name; | |
} | |
get name() { | |
return this._name; | |
} | |
get respectableName() { | |
return this._name + '様'; | |
} | |
} | |
var cat1 = new Cat('タマ'); | |
console.log(cat1.name); // タマ | |
console.log(cat1.respectableName); // タマ様 | |
var cat2 = new Cat('コタロー'); | |
console.log(cat2.name); // コタロー | |
console.log(cat2.respectableName); // コタロー様 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment