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

Show parent comments

19

u/[deleted] Aug 10 '12 edited Aug 10 '12

Digits are glyphs. Their sequence represents a number. They are not numbers.

0

u/[deleted] Aug 10 '12

[deleted]

11

u/[deleted] Aug 10 '12

In this very case it's really necessary. Because when you sum up numbers 1 and 2 you get number 3. But in article digits 1 and 2 are "summed" and result is number 12.

3

u/mattaereal Aug 10 '12

Well, actually to get 12 you must add: "1" + "2", which is not the same as adding: 1 + 2.

First strings, then numbers, you can also add "1" + 2, and 2 will be casted to string.

To use them as a number just add a simple + in front of them.

+("1" + "2")

+("1" + 2)

→ More replies (3)