属于类所独有的
        特点:通过类名去调用
class Person{constructor(name,age){this.name = name;this.age = age;}static sayName(){console.log("name");}}var p = new Person("zhou",22);Person.sayName()
静态方法和普通方法的关系
1.在普通方法中能调用静态方法
2.在静态方法中不能调用普通方法
// 1.在普通方法中能调用静态方法// 2.在静态方法中不能调用普通方法class Person{constructor(name,age){this.name = name;this.age = age;}sayAge(){person.sayName();console.log(this.age);}static sayName(){this.sayAge();console.log("name");}}var p = new Person("name",22)person.sayAge()
this
        1.静态方法:静态方法是属于类所独有的,类创建的时候,就会在内存中存在。不用实例化,
        直接通过类名直接调用,不会造成系统资源的格外浪费
        2.不能在静态方法中调用普通方法
        3.静态方法中的this,指调用静态方法的这个类
        4.静态方法是可以被继承的
        在静态方法this指—>调用静态方法的类
/*1.静态方法:静态方法是属于类所独有的,类创建的时候,就会在内存中存在。不用实例化,直接通过类名直接调用,不会造成系统资源的格外浪费2.不能在静态方法中调用普通方法3.静态方法中的this,指调用静态方法的这个类4.静态方法是可以被继承的*///在静态方法this指-->调用静态方法的类class Person{constructor(name,age){this.name = name;this.age = age;}sayAge(){person.sayName();console.log(this.age);}static sayName(){console.log(this);console.log("name");}}Person.sayName()
静态方法和继承
        1.子类可以继承父类的静态方法
        2.在子类的静态方法中调用父类的静态方法,可以通过super/this去调用
/*1.子类可以继承父类的静态方法2.在子类的静态方法中调用父类的静态方法,可以通过super/this去调用*/class Person{static baseUrl = "https://www.baidu.com"static sayName(){console.log("name");}}class Teacher extends Person{static sayAge(){super.sayName();console.log(super.baseUrl);console.log("age");}}Teacher.sayName()console.log(Person.baseUrl)
