//存储器: 让我们可以有效的控制对于对象的成员的访问 通过getters或者setters进行操作 (function () { var Person = /** @class */ (function () { function Person() { this.firstName = 'A'; this.lastName = 'B'; } Object.defineProperty(Person.prototype, "fullName", { get: function () { return this.firstName + '_' + this.lastName; }, set: function (value) { var names = value.split('_'); this.firstName = names[0]; this.lastName = names[1]; }, enumerable: false, configurable: true }); return Person; }()); var p = new Person(); console.log(p.fullName); p.firstName = 'C'; p.lastName = 'D'; console.log(p.fullName); p.fullName = 'E_F'; console.log(p.firstName, p.lastName); })();