Last active
January 2, 2018 18:53
-
-
Save luixaviles/2b32e83551cd7649caa9d7dc8deb2736 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
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