Object Getter Setter
const book = {
get name() {
return this.title ?? 'no title';
},
set name(val) {
document.
body.
innerHTML += `name changed to "${val}"<br>`;
this.title = val;
}
};
console.log(book.name);
book.name = 'Math Book';
book.name = 'JavaScript Book';
Getter setter syntax for Object literal.