const obj = {
a: 1,
b: 2,
c: {
c1: 3,
c2: 4
}
}
const nObj = new Proxy(obj, {
has: function (target, prop) {
var res = Reflect.has(target, prop);
console.log('Proxy.has', prop, target === obj);
return res;
},
get: function (target, prop) {
var res = Reflect.get(target, prop);
console.log('Proxy.get', target, prop);
return res;
},
set: function (target, prop, value) {
var res = Reflect.set(target, prop, value);
console.log('Proxy.set', target, prop, value);
return res;
},
deleteProperty: function (target, prop) {
var res = Reflect.deleteProperty(target, prop);
console.log('Proxy.delete', target, prop);
return res;
}
})
console.log(nObj)
console