News for hackers. Stuff that matters.
Re:JavaScript ( (__ = $ + $)[+$] + ({} + $)[_/_] +({} + $)[_... by loganlinn on Friday January 21, 2011 @10:15PM (#2129800)
Great use of JavaScript's weird + operator.

The whole trick stems from the fact that !$ == false and !$+$ == "false"

Re:JavaScript ( (__ = $ + $)[+$] + ({} + $)[_/_] +({} + $)[_... by weixiyen on Friday January 21, 2011 @10:22PM (#2129812)
var $ = []

![] == false because [] exists.

false + [] == 'false' because anything added to an array will become whatever that is as a string plus the contents inside the array.

2 + [] is also a string "2"

2 + [2,2] will become "22,2" (string)

Re:JavaScript ( (__ = $ + $)[+$] + ({} + $)[_/_] +({} + $)[_... by hencq on Saturday January 22, 2011 @06:47AM (#2130313)
Wow, I knew the + operator was weird, but didn't realise it allowed you to do stuff like that.

What I don't get though, wouldn't you still need to call eval() on it to do anything with it? Or does javascript do a 'implied eval' when you try to call a string?

Re:JavaScript ( (__ = $ + $)[+$] + ({} + $)[_/_] +({} + $)[_... by hencq on Saturday January 22, 2011 @07:46AM (#2130353)
Ah found the answer to my own question in the reddit thread about the same thing: http://www.reddit.com/r/programming/comments/f6xto/_/c1dr729
Re:JavaScript ( (__ = $ + $)[+$] + ({} + $)[_/_] +({} + $)[_... by joakin on Saturday January 22, 2011 @10:31AM (#2130499)
This is what is missing in the article, thank you