1// Use a Proxy object with getter/setter traps instead
2const obj = {};
3
4const proxObj = new Proxy(obj, {
5 get(obj, prop) {
6 console.log(`Getting ${prop} from `, obj));
7 return obj[prop];
8 },
9 set(obj, prop, newValue) {
10 console.log(`Setting ${prop} with value ${newValue} on `, obj));
11 return obj[prop] = newValue;
12 },
13});