SOURCE

var person = {name: "steve"};
console.log(person.name)
console.log(person.age)

var proxyPerson = new Proxy(person, {
    get: function(target, property){
        if(property in target){
            return target[property];
        }else{
            throw new ReferenceError('Property \"' + property + '\" does not exist.') 
        }
    }
})
console.log(proxyPerson.name);
// console.log(proxyPerson.age);

var child = Object.create(proxyPerson);
console.log(child.name)

let personAge = new Proxy({}, {
    set: function(obj, prop, value){
        if(prop === "age"){
            if(!Number.isInteger(value)){
                throw new TypeError("The age is not an integer")
            }
            if(value > 200){
                throw new RangeError('The age seems invalid')
            }
            obj[prop]=value;
        }
    }
})

personAge.age = 100
console.log(personAge.age)
console 命令行工具 X clear

                    
>
console