在普通对象中,我们可以推送到普通数组值,如 obj.l =[]; obj.l.push("测试")
例子。
var prxy = new Proxy({} , {
get(target, name){
return target[name]
},
set(target,name, value){
target[name] = value;
return true;
}
})
prxy.h = {test : "test"}
>> {test: "test"}
prxy.h
>>{test: "test"}
prxy.h.push("test")
>>VM2724:1 Uncaught TypeError: prxy.h.push is not a function
at <anonymous>:1:8
Run Code Online (Sandbox Code Playgroud)