使用简单的旧函数和“获取”之间有什么区别? 我可以轻松地用老式功能替换“获取”吗?
class Person {
constructor(name = "Tom"){
this._name = name;
}
getName() {
return this._name.toUpperCase();
}
get name() {
this._name = value.toUpperCase();
}
}