class Person {
constructor (name, age) {
this.name = name;
this.age = age;
}
set name (name) {
console.log("setter");
this._name = name;
}
get name () {
console.log("getter");
return this._name;
}
// 加一个成员方法
sayName () {
console.log(this.name);
}
}
The set get definition function here does not have the ES6 abbreviation of the previous set get. Why is the function here called by default during assignment
Refer to this article/a/11...