Transform a JavaScript code into an equivalent JavaScript code using only 6 characters.
Project implementation hightly relies on ways web-browsers dysplay some datatypes. It is supposed to work under both Firefox and Google Chrome.
Nonetheless -c <positive number>
should work on every browser.
js6chars makes it possible to convert JavaScript data into their equivalent versions using only a 6-character subset: []+()!
js6chars syntax:
-c <character> : string of one character
-n <number> : number
-s <script> : script
-t <text> : string
Example:
:$ ./build/js6chars -c 0
> +[]
- conversion to Boolean: add ! in front of the data -- eg.:
!1 === false
- conversion to Number: add + in front of the data -- eg.:
+"3" === 3
- conversion to String: add +[] to dta -- eg.:
undefined+[] === "undefined"
- Numbers from 0 to 9:
+[] === 0
++[[]][+[]] === 1
++[++[[]][+[]]][+[]] === 2
- ...
++[N][+[]] === N+1
- Numbers' string representation:
++[[]][+[]]+[] === "1"
- undefined:
[][0] === undefined
-- d,e,f,i,n,u [][+[]] === undefined
[][+[]]+[] === "undefined"
([][+[]]+[])[+[]] === "u"...
NaN === +("u")
-- a,N1e+308 === 1e308
-- +function find() { [native code] } === []["find"]
-- c,o,t,v, ,(,),[,],{,}true === !![]
-- rfalse === ![]
-- l,sfunction Number() { [native code] } === (0).constructor === (0)["constructor"]
-- b,m,rfunction Array() { [native code] } === (0).constructor === []["constructor"]
-- y,Afunction String() { [native code] } === (0).constructor === ([]+[])["constructor"]
-- g,Sfunction Function() { [native code] } === (0).constructor === []["constructor"]["constructor"]
-- Ffunction Boolean() { [native code] } === (0).constructor === (![])["constructor"]
-- B- Characters from a to z
"a" === 10["toString"](11)
"b" === 11["toString"](12)
- ...
"C" === Function("return atob(\"20N\")[1]")()
- All other characters:
([]+[])["constructor"]["fromCharCode"](\d+)
Project inspired by: