MCPcopy Create free account
hub / github.com/SincereCSL/Playgrounds / Dog

Class Dog

TypeScript/StudyTypeScript/src/class_01.ts:2–14  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1/// 类 :继承和成员修饰符
2class Dog {
3 constructor(name: string) {
4 this.name = name
5 }
6 // protected constructor(name: string) { //这个类不能被实例化,只能被继承
7 // this.name = name
8 // }
9 name: string
10 run() {}
11 protected pro() {} //受保护成员,只能在类和子类中访问,不能在类的实例中访问
12 readonly legs: number = 4
13 static food: string = 'bones' // 类的静态成员,只能通过类名调用,不能通过实例调用
14}
15
16console.log(Dog.prototype)
17let dog = new Dog('tiny')

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected