Open
Description
const quoteless = new Proxy({}, {
get(_, key) {
if(key === Symbol.unscopables) return {}
if(key === "__global") return globalThis
return `${key} `
},
has(_, __) {
return true
}
})
with (quoteless) {
__global.console.log(This + is + black + magic)
}
This outputs "This is black magic" to the console.
The way this works is that when a property is accessed then it just gets the name of the property that was accessed. Using with (quoteless)
makes all the properties be accessible without quoteless.property
. The way we access console.log is by checking if the key is a magic word, such as __global
, to access the globalThis.
My explanation is terrible, don't use it in the real repository lol