2019-06-10

    class Person {
      constructor(name, age) {
        this.name = name;
        this.age = age;
      }
      getName() {
        return this.name;
      }
      static a = 20;
      b = 30; //this.b = 30
      sayName = () => this.name; //this.sayName = () => this.name
    }
    let person = new Person("JonSnow", 21);
    console.log(Person.a);
    console.log(person.b);
    console.log(person.sayName());
    class Person {
      constructor(name, age) {
        this.name = name;
        this.age = age;
      }
      getName() {
        return this.name;
      }
    }
    class Student extends Person {
      constructor(name, age, sex, hoddy) {
        super(name, age);
        this.sex = sex;
        this.hoddy = hoddy;
      }
      getHoddy() {
        return this.hoddy;
      }
    }
    let student = new Student("JonSnow", 21, "男", "clean");
    console.log(student.sex);
    console.log(student.getHoddy());

你可能感兴趣的:(2019-06-10)