I came across a claim that arbitrary JavaScript can be generated and run using only letters, plus, minus, equals, commas and spaces. How could that work without quotes or parentheses, and does it have any practical use?
Can you really run JavaScript without quotes or parentheses?
Answers
The idea is to make the runtime produce the things you cannot write directly. Strings can be assembled through coercion and built-in properties rather than quoted literals. The resulting text can then be used as code.
The claimed technique uses Error.prepareStackTrace and changes to built-in prototypes to get functions invoked and influence their arguments without writing a normal parenthesized call. That is a pretty unusual route through the language and runtime, not a general coding style.
Reply to this answer
This is in the same puzzle family as JSFuck, which builds JavaScript from a tiny set of characters using coercion tricks. The character rules are different here, but the basic fun is finding ways to make the language supply what the source text leaves out.
Reply to this answer
Mostly a language puzzle, as far as normal development goes. It might be interesting to security researchers testing character-based filters, but bypassing a particular filter would depend on its rules and the runtime involved. The claim alone does not establish a working bypass.
Reply to this answer
Add your answer
Answers are reviewed before publication.
_x57~claywinder.6:
One caveat: Error.prepareStackTrace is an engine-specific hook, so this is not necessarily portable to every JavaScript runtime.