Skip to content

Instantly share code, notes, and snippets.

@gitfaf
Created August 18, 2017 01:54
Show Gist options
  • Save gitfaf/204d8be3e3cc09f05ab9958b740ef100 to your computer and use it in GitHub Desktop.
Save gitfaf/204d8be3e3cc09f05ab9958b740ef100 to your computer and use it in GitHub Desktop.
class Person {
constructor (fname, lname) {
this.lastName = lname;
this.firstName = fname;
}
get fullName () {
return this.firstName + " " + this.lastName;
}
toString () {
return `${this.fullName} aka ${this.nickName}`;
}
set nickName (value) {
this.nick = value;
}
get nickName () {
return this.nick;
}
}
let me = new Person('Git', 'Faf');
me.nickName = 'jifuf';
me.toString(); // Git Faf aka jifuf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment