为什么我的程序运行时sex可以修改成female,并不报错
let Person = {
name: 'yue',
sex: 'male',
age:14
};
let person = new Proxy(Person,{
get(target,key){
return target[key];
},
set(target,key,value){
if(key!=='sex'){
target[key] = value;
}
}
});
console.table({
name:person.name,
sex:person.sex,
age:person.age
});
try{
person.sex='female';
}catch(e){
console.log(e);
}finally{
}