The trick is that Proxy is not a type, it's a constructor.let foo = new Proxy({ value: 0 }, { get: (v) => v.value * 2 });
The type of foo will be the same as the type of the target object.
let my_arr = [];
// Proxy(target, handler)
let arr_proxy = new Proxy(my_arr, {
get(target, prop) {
console.log(`\n Getting ${prop}`);
console.log(`Perform needed actions after getting ${prop}`);
return target[prop];
},
set(target, prop, value) {
console.log(`\n Setting ${prop} ${value}`);
console.log(`Perform needed actions after setting ${prop} ${value}`);
target[prop] = value;
return true;
}
})
arr_proxy.push('dsfdgdf')