Created
June 1, 2017 17:31
-
-
Save matthieu-D/5df5cc3cb910c60067aea47f66a5f25b 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 Person { | |
private _name: string; | |
constructor(name: string) { | |
this._name = name; | |
} | |
get name(): string { | |
return this._name; | |
} | |
set name(name: string) { | |
this._name= name; | |
} | |
} | |
let person = new Person("John"); | |
console.log(person._name); //Bad | |
person.name = "Jane"; | |
console.log(person.name); // Good |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment