JS: Class getters/setters vs. just changing property directly

前端 未结 0 574
眼角桃花
眼角桃花 2021-02-02 11:13
class Person {
  constructor(name) {
    this._name = name;
  }

  get name() {
    return this._name.toUpperCase();
  }

  set name(newName) {
    this._name = newName;         


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题