Proxy object
Fri Oct 04 2024 21:02:22 GMT+0000 (Coordinated Universal Time)
Saved by
@kanatov
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!'
content_copyCOPY
Comments