aemkei / jsfuck

Write any JavaScript with 6 Characters: []()!+
jsfuck.com
Do What The F*ck You Want To Public License
8.16k stars 674 forks source link

Should replace predefined strings to its equivalent #8

Closed hazzik closed 11 years ago

hazzik commented 11 years ago

false => ![]

not to

(![]+[])[+[[+[]]]]+(![]+[])[+[[+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]]

etc

mathiasbynens commented 11 years ago

There is a difference. ![] results in the boolean value false, while (![]+[])[+[[+[]]]]+(![]+[])[+[[+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]] results in the string 'false'.

That said, the string 'false' can also be created using ''+![], but that would violate the core principle of jsfuck (i.e. to only use the []()!+ characters).

A shorter way to write 'false' that still follows jsfuck’s design would be ![]+[]. Similarly, true can be written as !![]+[].

hazzik commented 11 years ago

yep, I meant ![]+[] for strings and ![] for booleans. for example, if we are doing so: alert(false) it should be "alert("+![]+")"