Once resting in the couch, I remembered a wonderful passing movie from my childhood, which was called
WAT . And there was such a thing as bare words, which was shown on the example of Ruby.
“Bare words” (barewords) are words without quotes that you can use as strings.
In JavaScript, they seem not to be, so I tried to shove them into it, which generally turned out.
This is the result of this code:
')
with(bareWords) { alert( + ) console.log(We, can, use, bare, words) }
And he successfully displayed the necessary phrases.
And it was implemented like this:
try { let self = this window.bareWords = new Proxy({}, { has: function(target, name) { return !(name in self) }, get: function(target, name) { return name }, }) } catch(e) { console.error('Your browser doesn\'t support bare words.') }
As you can see, so that we could use bare words, we used such javascript features as
Proxy and
with .
When trying to get a property from this, due to the machinations with, the request goes to the proxy, where we return a string value instead of a malicious error about the absence of a variable.
Thanks for attention.

If anything, here is a reference on
Github