r/programming • • Aug 10 '12

Write any javascript code with just these characters: ()[]{}+!

http://patriciopalladino.com/blog/2012/08/09/non-alphanumeric-javascript.html
1.3k Upvotes

288 comments sorted by

View all comments

-2

u/trevdak2 Aug 10 '12

Only thing that irked me aobut this article was creating 1-10 instead of powers of two, but that's really just my preference over yours.

21

u/[deleted] Aug 10 '12

They are not numbers, they are digits.

→ More replies (25)

5

u/rooktakesqueen Aug 10 '12 edited Aug 10 '12

By default when JS unsafely casts a string to a number, it translates it using a decimal radix. So having access to the digits 0-9 is useful for allowing much shorter construction of every positive integer.

1

u/mattaereal Aug 10 '12

I'm sure it's possible to reduce the charset alphabet and increment the character encoding... and it's also possible to reduce the character encoding having a bigger charset alphabet, but powers of two?

1

u/inmatarian Aug 10 '12

The point of that exercise is to produce strings and values that can be executed via eval (or Function). In that context, Decimal is more useful than Binary because javascript parses decimal (and octal and hex). This process obfuscates the hell out of the code, and completely bypasses any static analysis, since the characters being used are all fundamental pieces of javascript.

1

u/trevdak2 Aug 10 '12

Ahh, that makes sense.