const handler = {
apply(target, thisArg, args) {
console.log('apply');
return Reflect.apply(target, thisArg, args) * 2;
},
construct(target, args) {
console.log('construct');
return { value: args[0] * 3 };
}
};
function Foo(x) { return x + 1; }
const ProxiedFoo = new Proxy(Foo, handler);
console.log(ProxiedFoo(5));
console.log(new ProxiedFoo(5).value); 