Skip to content

Instantly share code, notes, and snippets.

@lebowvsky
Created August 13, 2020 23:03
Show Gist options
  • Save lebowvsky/837fed96dcf3936c35ba48cc1c877b4b to your computer and use it in GitHub Desktop.
Save lebowvsky/837fed96dcf3936c35ba48cc1c877b4b to your computer and use it in GitHub Desktop.
POO en typescript 1
class Person {
private name: string;
private age: number;
constructor(name: string, age: number) {
this.name = name;
this.age = age;
}
tellMyName(): string {
return `I am ${this.name}`
}
tellMyAge(): string {
return `I am ${this.age} years old`
}
}
const person1 = new Person('John', 40);
console.log(person1.tellMyName());
console.log(person1.tellMyAge());
const person2 = new Person('Mary', 35);
console.log(person2.tellMyName());
console.log(person2.tellMyAge());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment