Explorer
project
index.css
index.html
index.ts
Dependencies
/*
LEARN TYPESCRIPT PART 3
classes
interfaces
interfaces with classes
*/
//basic javascript class
class Person {
name;
isCool;
pets;
constructor(n, c, p) {
this.name = n;
this.isCool = c;
this.pets = p;
}
sayHello() {
return `Hi, my name is ${this.name} and I have ${this.pets} pets`;
}
}
const person1 = new Person('Danny', false, 2);
const person2 = new Person('Sarah', 'yes', 6);