Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. class Person {
  2. protected name: string;
  3. protected constructor(theName: string) {
  4. this.name = theName;
  5. }
  6. }
  7.  
  8. class Employee extends Person {
  9. private department: string;
  10.  
  11. constructor(name: string, department: string) {
  12. super(name);
  13. this.department = department;
  14. }
  15.  
  16. public getElevatorPitch() {
  17. return `Hello, my name is ${this.name} and I work in ${this.department}.`;
  18. }
  19. }
  20. let howard = new Employee('Howard', 'Sales');
  21. let john = new Person('John');
  22. // constructor of class 'Person' is protected and only accessible within the class declaration.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement