Skip to content

Instantly share code, notes, and snippets.

@matthieu-D
Created June 1, 2017 17:31
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 matthieu-D/5df5cc3cb910c60067aea47f66a5f25b to your computer and use it in GitHub Desktop.
Save matthieu-D/5df5cc3cb910c60067aea47f66a5f25b to your computer and use it in GitHub Desktop.
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