Skip to content

Instantly share code, notes, and snippets.

@Takazudo
Last active October 5, 2015 00:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Takazudo/92b9c1bdc1a6d968838d to your computer and use it in GitHub Desktop.
Save Takazudo/92b9c1bdc1a6d968838d to your computer and use it in GitHub Desktop.
Cat
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