|
|
|
|
|
by jasonmcaffee
2499 days ago
|
|
Has anyone tried running the solution? It doesn't seem to work...
The below code results in the console logging the document object, which has the document object, and the code hits a ReferenceError when trying to log the 'a' variable.
Calls to p.whateverPropYouMakeUp result in the log 'get for target: ...' const proxyHandler = {
get(target, name){
console.log(`get for target: `, target, name);
return 'tacos';
},
}
const p = new Proxy({}, proxyHandler);
with (p){
console.log(`document with proxy: `, document);
console.log(`access random property: `, a);
}
https://jsfiddle.net/wf02n4gs/ |
|
https://jsfiddle.net/wepmLrh0/