Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Person(first, last) {
- this.firstName = first;
- this.lastName = last;
- Object.defineProperty(this, "fullName", {
- set: function(value) {
- const [newFirst, newLast] = value.split(' ');
- if (!newFirst || !newLast) { return;}
- this.firstName = newFirst;
- this.lastName = newLast;
- },
- get: function () {
- return this.firstName + ' ' + this.lastName;
- }
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment