ts-类


class Person {
  // 默认public  
  //private私有,不可访问  
  //protected子类可以访问,外部不可以访问
  // readonly 只可读,不可写
  // static 静态属性 当类的定义与实例状态没有太大关系的时候使用
  protected name:string;
  static stateVal:string[] = ['aaa','bbb'];
  static checkName(a){
    return a instanceof Person
  }
  constructor(name:string){
    this.name = name
  }
  funtest(){
    return `${this.name} is running`
  }
}
let person = new Person("aaaa");

console.log(person.funtest())


class lili extends Person{
  childTest(){
    return `${this.name} is child`
  }
}
let liliclass = new lili('liliname')
console.log(liliclass.funtest())
console.log(liliclass.childTest())

console.log(Person.checkName(liliclass))

class lilei extends  Person{
  constructor(name){
    super(name)
  }
  funtest(){
    return `${this.name} is funtestReload`
  }
}
let lileiclass = new lilei('lilei')
console.log(lileiclass.funtest())