封装记录

refactorgram

organization = {name: "Acme Gooseberries", country: "GB"};

image/svg+xml

class Organization {
  constructor(data) {
    this._name = data.name;
    this._country = data.country;
  }
  get name()    {return this._name;}
  set name(arg) {this._name = arg;}
  get country()    {return this._country;}
  set country(arg) {this._country = arg;}
}

别名将 Record 替换为 Data Class