alert(
(![]+[])[[]-[]]+
(([]+[])+([][[]]))[[]-[]]+
(([]+[])+([][[]]))[!![]-[]]
);
Heres' the fiddle: http://jsfiddle.net/leeny/6VugZ/
How exactly is this cryptic piece of code working?
alert(
(![]+[])[[]-[]]+
(([]+[])+([][[]]))[[]-[]]+
(([]+[])+([][[]]))[!![]-[]]
);
Heres' the fiddle: http://jsfiddle.net/leeny/6VugZ/
How exactly is this cryptic piece of code working?
vvvvvvv [0]
(![]+[])[[]-[]] = "false"[0]
^^^^^^^^ "false"
vvvvvvv again [0]
(([]+[])+([][[]]))[[]-[]] = "undefined"[0]
^^^^^^^^^^^^^^^^^^ "undefined"
vvvvvvvvv this time [1]
(([]+[])+([][[]]))[!![]-[]] = "undefined"[1]
^^^^^^^^^^^^^^^^^^ again "undefined"
Thus you get "f"+"u"+"n" === "fun".
"false"![] is false. +[] simply acts as a transformation into a string. Thus we gain the string "false".
"undefined"One of the operands needs to be a string. This is being done by []+[]. The actual undefined is created in the right hand side: [][[]] === [][0], the first entry of an empty array is undefined.