1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| class Dog{ constructor(name: string) { this.name = name; } public name: string = 'dog'; run(){} private pri(){} protected pro(){} readonly legs: number = 4 static food: string = 'bones' } console.log(Dog.prototype); let dog = new Dog('wangwang'); console.log(dog) // dog.pri() // dog.pro() console.log(Dog.food)
class Husky extends Dog { constructor(name: string, public color: string) { super(name); this.color = color; // this.pri() this.pro(); } // color: string; } console.log(Husky.food)
|