this.firstName = firstName;
this.lastName = lastName
}
getName(){
return this.firstName + ' ' + this.lastName;
}
get name(){
return `${this.firstName} ${this.lastName}`;
}
set name(string){
this.firstName = string.split(' ')[0];
this.lastName = string.split(' ')[1];
}
}
Person.prototype.name = ???; // Will this work?
// Maybe javascript provides the ability to add
// getter and setters to an existing class?
Обсуждают сегодня