aemkei / jsfuck

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

A better way of getting `A` #128

Closed 49b closed 1 year ago

49b commented 1 year ago

Running a function in Array.prototype and converting its output to string results in a string with the letter A.

Before:

(+[]+[]["constructor"])[10]

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


After:

([]["entries"]()+[])[8]

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

hazzik commented 1 year ago

This should be even smaller:

(NaN+[]["entries"]())[11]
hazzik commented 1 year ago

Actually, this is how it is already done in the master:

https://github.com/aemkei/jsfuck/blob/1f02651e98da1c13aef76d609755a2568a1aa6b4/jsfuck.js#L52

It was done in #110

I think this can be closed.