Skip to content

Instantly share code, notes, and snippets.

@luixaviles
Last active January 2, 2018 18:53
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 luixaviles/2b32e83551cd7649caa9d7dc8deb2736 to your computer and use it in GitHub Desktop.
Save luixaviles/2b32e83551cd7649caa9d7dc8deb2736 to your computer and use it in GitHub Desktop.
export class Person {
private id: number;
private firstName: string;
private address: string;
constructor(id: number, firstName: string, address: string) {
this.id = id;
this.firstName = firstName;
this.address = address;
}
showValues() {
console.log(this.number);
console.log(this.firstName);
console.log(this.address);
}
}
// Using access modifiers in constructor
// There's no need to declare attributes into the class.
export class Person {
constructor(private id: number, private firstName: string, private address: string) {}
showValues() {
console.log(this.number);
console.log(this.firstName);
console.log(this.address);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment