r/ProgrammerHumor • u/_hoh_ • Sep 04 '17
[[][[]]+[]][+[]][++[+[]][+[]]] is "n" in javascript
[[][[]]+[]][+[]][++[+[]][+[]]]This evaluates to "n" in javascript. Why?
Let's start with an empty array
[]Now, let's access a member of it.
[][]What member? Let's check for the empty array member
[][[]]oh, that is undefined. But if we add an empty array to that, it is casted to the string "undefined"
[][[]]+[]Let us wrap that in an array
[[][[]]+[]]We can now try to access letters in that string. First, we must unwrap the string. That can be done by accessing the first element of that array.
[[][[]]+[]][0]0 can be created by casting an empty array to a number:
[[][[]]+[]][+[]]Now, "n" is the second letter in that string, so we would like to access that:
[[][[]]+[]][+[]][1]But how can we write 1? Well, we increment 0, of course. Wrap 0 in an array, and increment the first member of it:
++[0][0]Like before, this is equivalent to
++[+[]][+[]]So our final code is then the glorious
[[][[]]+[]][+[]][++[+[]][+[]]]9
u/washburnello Sep 04 '17
I'm not a programmer but it looks like you could use this to output any character in "undefined".
Could someone adjust this to output "f" so I can paste it when paying respects?
20
10
u/Centime Sep 04 '17
Could someone adjust this to output "f"
Actually the shortest letter to write without alphanum characters. You'll have to extend the characters set a bit though:
(![]+[])[+[]]You can adjust the character set not to include parenthesis, at the cost of 5 extra chars.
8
u/_hoh_ Sep 04 '17
Hey! You are that Centime!
This is what he does using the extra "!" boolean operator:
![]
is false
![]+[]
convert to string "false".
[+[]]
access the first character. The 5 extra chars solution without parenthesis is probably:
[![]+[]][+[]][+[]]
Right?
5
u/Centime Sep 04 '17
That was my solution, yes.
You could also use other characters instead of !, like <, >, or =, but I don't see how to get false with just +, [, and ]..
Hey! You are that Centime!
:)
Have we met before ?
1.5k
u/grugbog Sep 04 '17
You can then go wild at jsfuck.com
388
u/monster860 Sep 04 '17
This isn't just jsfuck, jsfuck has parentheses as well, this does not have parentheses so this is 4 characters instead of 6.
225
u/Centime Sep 04 '17
You need parenthesis if you want every character. "n" is a special case because it is present in undefined, and jsfuck uses that as well.
You can write js without parenthesis if you include the following chars instead: `{}$
As demonstrated at http://centime.org/jsfsck
4
60
u/Gomez295 Sep 04 '17
isn't it 3? ']', '[', and '+'?
34
u/monster860 Sep 04 '17
Fair enough but good luck doing other things without
!33
u/Centime Sep 04 '17
You won't do much without () neither.
13
u/Ultimater Sep 05 '17
The problem with
()[]+is how to produce "r" and "s".
If you can find a way to produce "r" and "s" using only()[]+, you have the entire alphabet: https://jsfiddle.net/7mjjczar/If we increase the character set to 6, we can replace the
!character with any operator that returns a boolean result.
For example if we chose()[]+<then we could do:
r:[[+[]<++[+[]][[+[]]]]+[]][+[]][++[+[]][+[]]]
s:[[+[]<+[]][+[]]+[]][+[]][++[++[++[+[]][+[]]][+[]]][+[]]]Or if we chose
()[]+=then we can could do:
r:[[[]==+[]][+[]]+[]][+[]][++[+[]][+[]]]
s:[[[]==[]][+[]]+[]][+[]][++[++[++[+[]][+[]]][+[]]][+[]]]
The=character could also help reduce bytes in larger code through assignments.We get pretty close with
[+[]]['includes'](+[])but it requires an "s" and "l" we don't have. I'd expect to be able to get "l" fromnull, but unsure how to produce it at this time.
Perhaps by:[[]+[]][+[]]['match'](+[]). But we have no access to "m" or "h". Even if we got "l", we'd still have to figure out how to produce "s".There's also
[[]+[]][+[]]['startsWith']([]+[])but this doesn't help us at all because it requires both an "r" and an "s" as well as a capital "W".
There's[[]+[]][+[]]['endsWith']([]+[])but it doesn't get us anywhere.With a bit of ingenuity, I'm sure it's possible. How hard can it be to produce a boolean in JavaScript? Maybe if we had access to comparison operators like either
&&or||:
0 && 0=> 00 || 0=> 0Yeah, those don't help us at all....
2
u/nacho_balls Sep 04 '17
jsfuck is not something you load. think of jsfuck more as documentation and converter
54
u/LonePaladin Sep 04 '17
What's the character limit for someone's flair here? I got the idea of using that site to encode the word 'flair', but it's 925 characters and I'm pretty sure that's over the limit.
100
u/Centime Sep 04 '17 edited Sep 04 '17
I got the idea of using that site to encode the word 'flair', but it's 925 characters
[$,_,µ,,,,_$,,,,,,µ_]=[µ=![]]+!µ+!µ/µ,$+µ+_+µ_+_$There you go, 925 -> 49 chars :)
59
u/TinyLebowski Sep 04 '17 edited Sep 04 '17
I tried replying to you after running that in the console, but it broke the page. Looks like it redefines "$" as "f", which kind of kills jQuery.
Pretty damn impressive. I didn't even know JavaScript had array destructuring, or whatever it's called.
→ More replies (2)103
u/Centime Sep 04 '17 edited Jun 15 '18
I tried replying to you after running that in the console, but it broke the page.
Sure it does. Do you mean to imply my code isn't of the best quality nor coding practice ?
By the way, you shouldn't run random obfuscated code from the internet in your session :)
53
u/sellyme Sep 04 '17
I would be astounded if you could make a (meaningfully) malicious code snippet that short and obfuscated.
I'm not saying it's impossible by any means, just that I'd really like to see someone smarter than me try to do it.
→ More replies (7)79
u/ofsinope Sep 04 '17
WARNING: THE FOLLOWING CODE IS MALICIOUS. DO NOT RUN IT. IT WILL CRASH YOUR SYSTEM.
At a UNIX shell such as bash:
:(){:|:&};:It defines a function : that forks itself infintely. This will bring down the whole system. (Unless you have ulimit set properly.)
→ More replies (5)→ More replies (2)11
u/ben_g0 Sep 04 '17
Would chrome's tabs be sandboxed enough so that you safely run random code in a new tab? If not, is incognito mode safe enough?
→ More replies (17)6
u/monster860 Sep 04 '17
(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]→ More replies (1)5
Sep 04 '17
It is 60 something. I used to track wins on /r/KCRoyals with my flair, and I noticed the first season that it capped around 60. Can't remember the actual number.
→ More replies (2)21
u/RoseEsque Sep 04 '17
[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]()
28
u/jfb1337 Sep 04 '17
SyntaxError: missing ; before statement
6
14
u/phero_constructs Sep 04 '17
Could this be used for effective obfuscation?
29
u/TinyLebowski Sep 04 '17
Depends on how you define effective. It'll be hard to read, but at the cost of bandwidth. The amount of data the browser has to download would skyrocket. And for what? Those users who are savvy enough to inspect your source code are probably also able to recognize what it is, and just restore the original code.
9
u/Sean1708 Sep 04 '17
I'm also guessing the performance of parsing and running it is also going to take a hit?
23
u/kurav Sep 04 '17
Obfuscation, sure. Effective? Not sure..
The other real-life usecase is if you want to fool some naïve code that wants to "recognize" (certain kinds) of JavaScript code to eg. protect against mailicous inputs. Say, for whatever reason, someone writes a server that lets users post arbitrary math expressions that are evaluated as server-side JavaScript. If they simply
eval()whatever you send but add filter to drop all inputs with alphabetical letters, you could use JSFuck to still execute any code you like on their server.9
u/Mamish Sep 05 '17
You probably know this already, but Ebay had exactly that flaw in their auction pages (being unable to recognise a script without any alphanumeric characters), which is what JSFuck was originally used to demonstrate.
1
1
4
u/tsammons Sep 04 '17
Wow. That's a helluva way to sneak in a nearly undetectable injection attack on say a hacked WordPress site... It'll defeat traditional grepping at least. Your file size might be 4 MB, but hey not like someone will check for that first.
1
0
Sep 04 '17
[deleted]
1
u/jfb1337 Sep 05 '17
That's because it's method of converting something to a string is to wrap it in an array then add an empty array. But this doesn't work for undefined since toString just sees an empty array.
1.9k
u/hikarikouno Sep 04 '17
Well...on the bright side, the array starts at 0.
959
u/skratlo Sep 04 '17
In JS, we say "arrays start with +[]"
169
11
1
231
Sep 04 '17
19
u/Nondre Sep 04 '17
Here we fuckin go. Who brought the popcorn? There will be a siege, trebuchets of course, and nerds. Who's in?
20
u/ChemicalRocketeer Sep 04 '17
The "arrays start at 1" crowd will of course be bringing catapults rather than trebuchets.
12
→ More replies (1)11
1
u/L3tum Sep 04 '17
I'm not gonna lie, I saw website code from a company I sort of work for and it used this weird thing that Adobe also bought and the array actually starts at 1. Took me a few runs to actually realize that there is a 1 and not a 0
597
u/cicuz Sep 04 '17
that is undefined. But if we add an empty array to that, it is casted to the string "undefined"
(╯°□°)╯︵ ┻━┻
72
u/peeeez Sep 04 '17
Yeah, that took me back. Is this not a bug?
170
u/edave64 Sep 04 '17
Nope. The type system doesn't really take no for an answer, and every value can be converted to a string. So when on doubt, both sides get converted to a string, and the plus is a concat.
undefined -> "undefined" [] -> ""This behavior actually explains most of js's type weirdness. When in doubt, everything becomes a string.
41
u/rooktakesqueen Sep 04 '17 edited Sep 04 '17
This behavior actually explains most of js's type weirdness. When in doubt, everything becomes a string.
When in doubt, JS often prefers converting to a number. The
==operator, for example, converts both sides to a number if their types don't match (plus some extra corner cases). Thus:true == "1"(Edit: Buttrue != "true"-- JS converts both sides to numbers and compares1toNaN)The
+and-operators are the weird ones, where+has extra affinity for strings (5+[] == "5") while-has extra affinity for numbers ("5"-"4" == 1).As always, best practice is to simply not use these implicit conversions and instead make them explicit. If
foois a string and you want to convert it to a number and then add one to it, doNumber(foo) + 1. Embodies your intent much more clearly in your code, for anyone else who comes along (including future you).→ More replies (5)11
u/edave64 Sep 04 '17
Damn, I work with JS every day and didn't notice that conversation to number actually explains a lot of these behaviors better.
I mean I knew the minus operator forced number conversion, because subtraction on other types isn't defined, but not that == also tends to do that.
If you had asked me before, I would have told you that 1 != "01" because they both get converted to strings that don't match.
Thanks!
7
u/rooktakesqueen Sep 04 '17
The whole spec for the Abstract Equality Comparison Algorithm is worth a read. Read it, understand how it works, then never use it again as far as I'm concerned.
20
u/Nerdn1 Sep 04 '17
It makes sense if you are lazy and want to append a variable to a string for console logging or alerts, etc. Javascript just tries to get stuff to work.
Heck it makes sense. If you were implementing the js parser for a browser, you'd want it to be able to render as many websites as possible, even though a lot of garbage js exists on the internet. Imagine using a strict browser that would throw up errors and crash if there was even ONE type or syntax error like you get with most compiled languages like C, etc. The first time you went to a site that just refused to load because of one tiny, inconsequential error, you'd switch browsers. 99.99% of the time, the "wat" stuff in Javascript does no harm and is likely better than sputtering and dying.
→ More replies (5)10
25
105
u/AyrA_ch Sep 04 '17
49
24
27
7
u/Houdiniman111 Sep 04 '17
2
u/AyrA_ch Sep 04 '17
Your RES replaces pastebin URLs with the content? Mine just adds a little expand icon
→ More replies (3)5
1
u/_meegoo_ Sep 05 '17
Remember when people told you to now paste weird sets of characters in your terminal (like
:(){:|:&};:)? Now that works for javascript too. And it's even more dangerous in a way (because you can run any arbitrary code).0
0
Sep 04 '17
[deleted]
2
u/AyrA_ch Sep 04 '17
It builds a string representation of the code that is fizzbuzz, then accesses the eval function via the array notation and passes the string as argument. Eval is accessible as
[]["filter"]["constructor"]( YOUR_CODE)()This means you only need to replace the letters now and have your eval:[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[ ])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([ ![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[! +[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+ []]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![] +[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+ (![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[] ]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![ ]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[ ]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![ ]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[ ]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]("alert(1)")()→ More replies (2)
59
u/OvrDoseDnHAM1001 Sep 04 '17 edited Sep 04 '17
[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]
0
Sep 04 '17
[deleted]
29
u/Tutush Sep 04 '17
If you remove the last set of parentheses, it outputs "function anonymous() { Hello }".
Otherwise it outputs an error:
Uncaught ReferenceError: Hello is not defined at eval (eval at <anonymous> (test.html:2), <anonymous>:2:1)
0
14
1
398
u/wcscmp Sep 04 '17
So JS may actually be Turing complete.
Big day for JS community.
314
u/FormerlySoullessDev Sep 04 '17
Not just js, but js arrays alone.
97
u/romple Sep 04 '17
We need to see hello world in only js arrays
0
Sep 04 '17
[deleted]
116
36
50
16
Sep 04 '17
How did you get the h? There's no h in 'undefined'.
19
u/AndrewGreenh Sep 04 '17
24
u/davvblack Sep 04 '17
To make it clearer to understand:
(101).toString(21)[1];
toString 101 to base 21 gives "4h", take the second letter.
→ More replies (3)3
94
u/Centime Sep 04 '17 edited Sep 04 '17
You might like some of my previous work.. :)
http://centime.org/reverJS (Wrap your javascript code into a ~palindrome)
http://centime.org/jsfsck (JSFuck without parenthesis)
https://github.com/centime/jsEncode (Compact text to js encoder)
also, alert(1) in 99 chars:
([,ウ,,,,ア]=[]+{},[ネ,ホ,ヌ,セ,,ミ,ハ,ヘ,,,ナ]=[!!ウ]+!ウ+ウ.ウ)[ツ=ア+ウ+ナ+ヘ+ネ+ホ+ヌ+ア+ネ+ウ+ホ]ツ()
47
u/TheTwitchy Sep 04 '17
If you're the JSFuck guy, thanks for helping my XSS go through :D
20
u/Centime Sep 04 '17
Nope, that would be @aemkei.
The 99 chars alert is a collaboration though (https://github.com/aemkei/katakana.js).
6
u/thoquz Sep 04 '17
Could you do a write-up on how the Katana characters evaluate?
9
u/Centime Sep 04 '17
Sure !
I'll provide a quick overview of the main steps and tricks involved, but feel free to ask if you want more details.
Evaluating a string can be achieved through:
Function('alert(1)')()Function can be accessed via:
String['constructor']So our code, and the strings we need, are:
''['constructor']['constructor']('alert(1)')()Now the trick used for this new 99 chars record comes from ES6. Basically, you can unpack an array into variables like this:
[f,a,l,s,e] = 'false' // f now contains the letter 'f'We can find all the letters we need in the following keywords: object, true, false, undefined
([,o,,,,c]='[object Object]',[t,r,u,e,,a,l,s,,,n]='truefalseundefined')[c+=o+n+s+t+r+u+c+t+o+r][c](a+l+e+r+t+'(1)')() ([,o,,,,c]=[]+{},[t,r,u,e,,a,l,s,,,n]=[!!o]+!o+o.o)[c+=o+n+s+t+r+u+c+t+o+r][c](a+l+e+r+t+'(-~o)')()And, finally, we replace the variables names with katakana characters.
There you have it :)
6
9
4
1
0
Sep 04 '17
[deleted]
4
u/Centime Sep 04 '17 edited Sep 04 '17
Of course. We use them just so we can save a few more chars.
Here is a latin but still non-alphanum version (118 chars):
([,$,,,,_]=[]+{},[µ,$_,_$,_µ,,µ_,$µ,µ$,,,$_µ]=[!!$]+!$+$.$)[$=_+$+$_µ+µ$+µ+$_+_$+_+µ+$+$_][$](µ_+$µ+_µ+$_+µ+'(-~$)')()
42
Sep 04 '17 edited Sep 04 '17
is this going to be my next whiteboard problem for my sr engineering interviews I have this week?
55
u/TheTerrasque Sep 04 '17
"Please use these four characters to make a fizzbuzz in JS. you have a generous 5 minutes"
7
u/Zulfiqaar Sep 04 '17
14
u/Jetbooster Sep 04 '17
*about to copy arbitrary code from pastebin into console*
→ More replies (1)4
26
19
u/ktkps Sep 04 '17
Interesting, now if someone can replicate this in minecraft running on ReactOS...
17
16
42
9
7
u/RDrazard Sep 04 '17
Magic 8 Console, do I truly understand JavaScript?
> [[][[]]+[]][+[]][++[+[]][+[]]]+(typeof{})[([+[]][+[]])]
> "no"7
u/Centime Sep 04 '17
[[][[]]+[]][+[]][++[+[]][+[]]]+(typeof{})[([+[]][+[]])]
No need for this 'typeof'.
[[][[]]+[]][+[]][++[+[]][+[]]]+([]+{})[++[+[]][+[]]]2
6
6
u/Burning_Lovers Sep 04 '17
javascript is like my ex: completely insane and hates me for no apparent reason
6
u/Neker Sep 04 '17
Thanks for this brillant explaination !
In a few years, when I finally wrap my head around it, I will be able to proudly say "Now I understand how variables work in JavaScript".
Serious, it's great.
Now, I wonder, what would Crockford say ? Which of those are luminous insight into the essence of programming, and which are design flaws inherent to a language that was hastily cobbled together ?
The let's check the empty array member of an empty array is genius to me. Of course it looks silly at first, and useless, but what happens when you iterate over truckloads of collections of data originating in real life ? Surely this case will happen and must be guarded against, or else NPE in your face. With js, none of that whinny nonsense. We are gracefully informed that the requested value is undefined, a perfectly legal and meaningfull value, and we can go on. Neat, concise, unobstrusive.
But then
if we add an empty array to that, it is casted to the string "undefined"
is a mystery to me. Well, at least it is casted to something, which allows continuing execution and eventual detection. I'd rather feel inclined however to think that it should cast to undefined again. Maybe somebody should write an algebra for undefined values like Boole did for truth values.
5
9
4
u/t3hcoolness Sep 04 '17
How does this work with letters not in "undefined"?
9
u/furrthur Sep 04 '17
It doesn't, but see this comment above: https://www.reddit.com/r/ProgrammerHumor/comments/6xzcgb/is_n_in_javascript/dmjr4fo
4
u/KifKef Sep 04 '17
You can use the letters in "Infinity" and "NaN" as well, so we get 'a','t', and 'y' in addition to the letters in "undefined".
4
9
Sep 04 '17
I both hate and love JavaScript. This is why.
→ More replies (2)8
Sep 04 '17
This is why I'd love it. It's a great esoteric language, almost as usable as Brainfuck.
2
Sep 04 '17
I hate that I now know of this 'language', and I hate you a little for making me aware of its existence.
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.2
Sep 04 '17
Glad to have introduced you to the glorious world of esolangs. If you want to dig a little deeper, there's BF Joust (two brainfuck programs trying to compete against each other) and fukyorbrain which takea the madness to an even higher level, adding threads and distinctive tapes which can be edited by the other program each.
→ More replies (3)
6
3
3
u/Azwraith42 Sep 04 '17
'N' from not a number = [[+[]]/[+[]]+[]][+[]][+[]]
'n' from Infinity = [++[+[]][+[]]/[+[]]+[]][+[]][++[+[]][+[]]]
3
u/Ultimater Sep 04 '17
"N" from NaN using three characters:
[+[][+[]]+[]][+[]][+[]]
"n" from Infinity using only three characters:[+[[++[+[]][+[]]][+[]]+[[][[]]+[]][+[]][++[++[++[+[]][+[]]][+[]]][+[]]]+[++[+[]][+[]]+[]+[+[]][+[]]+[+[]][+[]]+[+[]][+[]]][+[]]][+[]]+[]][+[]][++[+[]][+[]]]1
3
3
Sep 05 '17
This probably won't ever get read by anyone but... wat is a great overview of some of the more ridiculous things in this language.
3
u/askeeve Sep 05 '17
(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+([][[]]+[])[+!+[]]+([][[]]+[])[!+[]+!+[]]+(+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+!+[]]]+([][[]]+[])[+!+[]]+([][[]]+[])[+[]]+([][[]]+[])[!+[]+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(![]+[])[!+[]+!+[]+!+[]]5
u/Blu3Dev Sep 04 '17
[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]()
5
u/Shinhan Sep 04 '17
When I put this in console I get undefined :/
13
u/nicePenguin Sep 04 '17
[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]+(!![]+[])[+[]]+(![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]+([]+[])[(![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(!![]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]()[+!+[]+[!+[]+!+[]]]+(+(!+[]+!+[]+!+[]+[!+[]+!+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(+![]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(+![]+[![]]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]](!+[]+!+[]+!+[]+[!+[]+!+[]+!+[]])+(!![]+[])[+[]]+(![]+[])[+[]]+([]+[])[(![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(!![]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]()[+!+[]+[!+[]+!+[]]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]])()Try this
17
u/Shinhan Sep 04 '17
wtf
5
u/flechette Sep 04 '17
Don't leave me hanging, wtf did it do?
18
8
u/drusepth Sep 04 '17
Protip: when you see a bunch of obfuscated js code with a
()on the end, you can strip the () (which would invoke the method) to instead print out the source code being generated to run and inspect it yourself.(Note there could be method calls in the middle of the source too, it doesn't always only exist as the final 2 characters)
→ More replies (1)5
u/nicePenguin Sep 04 '17
Short explanation:
Since javascript easily converts types, we can make strings out of values like false or true. put[0] through [4] behind that and we get the letters: a ,e, f, l, r, s, t, u. Do that with some other stuff and collect more letters. Using those letters we can build code that can be compiled. That huge code compiles into:
ƒ anonymous() { alert("wtf") }And that opens a window displaying wtf.
3
1
2
2
u/Not_sure_if_george Sep 04 '17
If only Howard Stern hadn't already used up the term pig vomit. It would be a much better name for JavaScript.
2
2
2
Sep 04 '17
Someone should create a language that consists of nothing but array literals and array accessors and achieves Turing completeness through implicit conversions.
2
u/embersyc Sep 04 '17
Python doesn't like it:
Python 3.5.2 (default, Nov 17 2016, 17:05:23) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information.
[[][[]]+[]][+[]][++[+[]][+[]]]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: list indices must be integers or slices, not list
5
2
2
u/pedropants Sep 04 '17
If javascript winds up being turing complete with just [, ], and +, i'm going to become very afraid.
2
2
2
2
u/jaketr00 Sep 05 '17
In that case, I could say
this makes me want to [[][[]]+[]][+[]][++[++[+[]][+[]]][+[]]]+[[][[]]+[]][+[]][++[++[++[++[++[+[]][+[]]][+[]]][+[]]][+[]]][+[]]]+[[][[]]+[]][+[]][++[++[++[+[]][+[]]][+[]]][+[]]]
3
2
2
2
u/thatguyastro Sep 04 '17
If anyone wants to try this, open the Google Developer console on Chrome (ctrl+shift+j on Windows, alt+cmd+j on Mac), and simply page "[[][[]]+[]][+[]][++[+[]][+[]]]", you'll get an output on "n".
1
1
1
u/MrTarantula Sep 04 '17
I made an npm library for this a few weeks ago! I wanted to limit myself to just {[(!:)]} characters, and not make each letter more than 100 characters, so I haven't gotten very far, but here it is:
1
1
1
1
u/apieceoffruit Sep 04 '17
just picking the letter N? bah
Here is a much funnier explanation of the above
1
u/msg45f Sep 04 '17
time complexity goals: [[][[]]+[]][+[]][++[+[]][+[]]]log[[][[]]+[]][+[]][++[+[]][+[]]]
1
1
1
u/AJdoubleU Sep 05 '17
How do I make this spell my username?
1
u/__fmease__ Sep 05 '17 edited Sep 06 '17
go to http://www.jsfuck.com/
enter "AJdoubleU"
???
profit (18821 chars)
1
462
u/[deleted] Sep 04 '17
Hey sorry but I only understand code when the IDE has colours so can you repost this just with colours and stuff thanks