function User(fullName) {
this.fullArr = fullName.split(' ')
}
User.prototype = {
get firstName() {
return this.fullArr[0];
},
set firstName(value) {
this.fullArr[0] = value;
},
}
// или
// Object.defineProperty(User.prototype, 'firstName', {
// get: function () {
// return this.fullArr[0];
// },
// set: function (value) {
// this.fullArr[0] = value;
// },
// })
Вообще код должен был выглядеть примерно так... почему?
https://github.com/azat-io/you-dont-...%D0%B8%D 1%8F
https://github.com/azat-io/you-dont-...ect-prototypes
https://github.com/azat-io/you-dont-know-js-ru