js object property getter setter
const obj = {
value: 0,
get prop() {
console.log(".prop accessed!");
return this.value;
},
set prop(newValue) {
console.log(".prop set! Value: ", newValue);
this.value = newValue;
}
}
console.log(obj.prop);
obj.prop = 42;
console.log(obj.prop);