JSFiddle - React, Tailwind, and code Playground
Proxy: as handler
JavaScript
const handlerProxy = new Proxy({}, {
get (obj, trap) {
return function (...args) {
console.log(`${trap}`, ...args);
const result = Reflect[trap](...args);
console.log(' result:', JSON.stringify(result));
console.log(' value:', JSON.stringify(args[0]));
};
}
});
console.clear();
const myObj = new Proxy({a: 1, b: 2}, handlerProxy);
myObj.a = 3;
delete myObj.b;