I'm using Chrome 60. I've just tried to apply a get
Proxy on window.location
.
It worked for the first two reference, however, then it failed with Illegal invocation
error:
location = new Proxy(location, {
get: (target, name) => {
console.log(name, target, "PROX");
return target[name];
}
});
The error messages were:
VM3495:3 Symbol(Symbol.toPrimitive) Location {…} "PROX"
VM3495:3 toString Location {…} PROX
Uncaught TypeError: Illegal invocation at :1:10
- Why did it throw the error?
- How do I apply
get
Proxy onwindow.location
in Javascript?