0
点赞
收藏
分享

微信扫一扫

react18-学习笔记12-类class

安七月读书 2022-08-27 阅读 142
编程语言

class Animal{
protected name: string;
static age=18
constructor (name:string){
this.name=name
}
run(){
return `${this.name}`
}
}
const snake=new Animal("geyao")
console.log(Animal.age)
class Dog extends Animal{
bark(){
return `${this.name}`
}
}
const dog=new Dog("geyao")

class Cat extends Animal{
bark(){
return `${this.name}`
}
}
const cat=new Cat("geyao")



举报

相关推荐

0 条评论