I came across this code snippet on a JS tutorial page and I'm not entirely sure about its functionality. Could you please explain what this piece of code does?
// Original source: https://javascript.info/property-accessors
let user = {
name: "John",
surname: "Smith",
get fullName() {
return `${this.name} ${this.surname}`;
},
set fullName(value) {
[this.name, this.surname] = value.split(" ");
}
};
// The "set fullName" function receives a specified value.
user.fullName = "Alice Cooper";
alert(user.name); // Alice
alert(user.surname); // Cooper