我的博客没有废话直接上代码,大家都能看懂
class Person {
constructor(name, age) {
this.name = name;
this.age = age;
}
sayHello() {
return `hello my name is ${this.name}, i'm ${this.age} years old!!`
}
}
const person = new Person("小明", 25)
person.sayHello()