ts重点学习65-类的继承笔记

export default {}


// static
class StaticTest {
  static salary: string;
  static say():void {
    console.log("我们想要的工资是: " + this.salary);
  }
}

StaticTest.salary = "18k";
StaticTest.say();

// instanceof
class Person {}
let p = new Person();
let isPerson = p instanceof Person;
console.log("p对象是Person类实例化来的嘛?" + isPerson);

class Student extends Person {}
let s = new Student();
let isPerson2 = s instanceof Person;
console.log("p对象是Person类实例化来的嘛?" + isPerson2

posted @ 2022-09-30 20:41  前端导师歌谣  阅读(31)  评论(0)    收藏  举报