Obfuscated Javascript.Explained()

And this, of course, evaluates to the string “fail”.
(![]+[])[+[]]+(![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]];
— Marcus Lagergren (@lagergren) May 23, 2013

Rewrite to show the four (string)[subscript] uses:
 (![]+[])        [+[]]
+(![]+[])        [+!+[]]
+([![]] + [][[]])[+!+[]+[+[]]]
+(![]+[])        [!+[]+!+[]];

Then evaluate each color-coded expression:
![]+[]  => "false"
+[]    => "0"
+!+[]  => "1"
!+[]   => 1

That third string really exercises those square brackets!
[![]] + [][[]] => "falseundefined"
                   01234567890123

Finally, we’re ready to ‘fail’:
[0]+[1]+[10]+[2]
 f + a +  i + l

Advertisements