CHALLENGE
const target = { a: 1, b: 2 };
const handler = {
get(obj, prop) {
return prop in obj ? obj[prop] * 2 : 'not found';
},
set(obj, prop, value) {
if (typeof value !== 'number') {
return false;
}
obj[prop] = value + 10;
return true;
}
};
const proxy = new Proxy(target, handler);
proxy.c = '5';
proxy.d = 5;
console.log(JSON.stringify({
a: proxy.a,
b: proxy.b,
c: proxy.c,
d: target.d,
hasC: Reflect.has(target, 'c')
}));
>>Click here to continue<<