function Sample(val) {
return {
val: {
get() {
console.log('getter');
return this.val;
},
set(val) {
console.log('setter');
this._val = val;
}
}
};
}
const sample = Sample(10);
sample.val = 999;