SHARE
TWEET

Untitled

a guest Oct 18th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Person{
  2.     private name: string;
  3.     private age: number;
  4.  
  5.     constructor(name: string, age: number){
  6.         this.name = name;
  7.         this.age = age;
  8.     }
  9.  
  10. tellMyName(): string {
  11.     return `I am ${this.name}`
  12. }
  13.  
  14. tellMyAge(): string {
  15.     return `I am ${this.age}`
  16. }
  17.  
  18. }
  19. const person1 = new Person ("John", 40);
  20. const person2 = new Person ("Mary", 35);
  21.  
  22. console.log(person1.tellMyName());
  23. console.log(person1.tellMyAge());
  24. console.log(person2.tellMyName());
  25. console.log(person2.tellMyAge());
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top