Last active
January 19, 2017 22:30
-
-
Save solominh/6ff07796c2032b468111a82a5417f0e9 to your computer and use it in GitHub Desktop.
This file contains 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 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