If you declare a class with a getter
class Person {
constructor(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
get fullName() {
return [this.firstName, this.lastName].join(" ");
}
}
you can access the getter after instantiating a new object
const person = new Person("Jane", "Doe");
console.log(person.fullName); // "Jane Doe"
but this won't work after copying the object using the spread operator
const personCopy = { ...person };
console.log(personCopy.fullName); // undefined
I think this is somewhat confusing syntax.