Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Any similarity is coincidental. This hack isn't doing anything semantic or syntactic to the code you provide: it's just encoding the string you provide into an equivalent string in another alphabet. The two alphabets happen to be identical in JavaScript.

For example, `+[]` equals the integer 0 (apparently the unary plus operator coerces the empty array to a boolean then converts to an integer), and `![]` of course equals the boolean false. Furthermore, JavaScript does some weird type coercion, so `false + []` equals the string "false". Replace the boolean false with `![]`, so `![] + []` equals the string "false". Now, if we need the letter "f" we just do `"false"[0]`, encoded as `(![] + [])[+[]]`. Remove spaces, and you can see that `(![]+[])[+[]]` is equivalent to "f".

People have figured out how to get tons of characters from small initial character sets. See this: http://sla.ckers.org/forum/read.php?24,33349,33405



Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: