Skip to content

Instantly share code, notes, and snippets.

@solominh
Last active January 19, 2017 22:30
Show Gist options
  • Save solominh/6ff07796c2032b468111a82a5417f0e9 to your computer and use it in GitHub Desktop.
Save solominh/6ff07796c2032b468111a82a5417f0e9 to your computer and use it in GitHub Desktop.
class Employee {
constructor(name) {
this._name = name;
}
doWork() {
console.log(`${this._name} is working`);
}
get name() {
return this._name.toUpperCase();
}
set name(newName) {
if (newName) {
this._name = newName;
}
}
}
let john = new Employee('John')
console.log(john.name)
john.name = 'John Doe'
console.log(john.name)
john.doWork()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment