请老师检查,谢谢
来源:3-3 编程练习
慕的地7233660
2022-06-13 11:54:04
class Person{
constructor(name,age){
this.name=name
this.age=age
// this.say=function(){
// console.log(this.name,this.age)
// }
}
run(){
console.log('run')
}
say(){
console.log (this.age,this.name)
}
static intor(){
return "this is a Person class"
}
static show(){
console.log('show')
}
}
const zs=new Person('张三',18)
zs.say()
zs.run()
console.log(Person.intor())
Person.show()1回答
好帮手慕慕子
2022-06-13
同学你好,say方法是添加到实例对象上的,建议书写在constructor里面,示例:

虽然目前静态属性还处于提案中,但是针对本练习题,intro是静态属性,建议调整下:

祝学习愉快~
相似问题