class Person {
static person = "张三"
constructor(name) {
this.name = name
//console.log(person) // person is not defined
console.log(this.person)// undefined
console.log(Person.person)// '张三'
}
getName(){
console.log(this.name)
//console.log(person) // person is not defined
console.log(this.person)// undefined
console.log(Person.person)// '张三'
}
static getPerson(){
console.log('person')
}
static getName(){
this.getPerson()//在static方法中调用另外一个静态方法可以用this
}
}
let p = new Person("李四")
p.getName()
//p.getPerson()// p.getPerson is not a function
Person.getPerson()
Person.getName()//'person'
console