const handler = { get: function(obj, prop) { return prop in obj ? obj[prop] : 'Property not found!'; } }; const person = new Proxy({ name: 'Alice' }, handler); console.log(person.name); // 'Alice' console.log(person.age); // 'Property not found!'
const handler = { get: function(obj, prop) { return prop in obj ? obj[prop] : 'Property not found!'; } }; const person = new Proxy({ name: 'Alice' }, handler); console.log(person.name); // 'Alice' console.log(person.age); // 'Property not found!'