let user = {
name: "Вася",
_password: "***",
a() {
console.log('123');
}
};
user = new Proxy(user, {
get(target, prop) {
if (prop.startsWith('_')) {
throw new Error("Отказано в доступе");
} else {
let value = target[prop];
return (typeof value === 'function') ? value.bind(target) : value; // (*)
}
}
})
console.log('123');
console.log('123', this);