有人可以解释以下输出
var handler = {
get: function(target,key, receiver){
return new Proxy(Reflect.get(target, key, receiver),handler);
},
apply: function(target, thisArg, args){
Reflect.apply(target, thisArg, args);
}
}
var p = new Proxy(window, handler);
p.alert("Alert"); // Throws illegal invocation error
var alias = p.alert;
alias("Alert") // Even this works which is baffling for me
var p = new Proxy(Reflect.get(window, "alert"), handler);
p("Alert"); // works as expected
第一条语句引发非法调用错误,而第二条则没有。他们两个看起来都和我一模一样,我不明白第一个语句为什么没有所需的this
上下文Reflect.apply