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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: