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
The whole trick stems from the fact that !$ == false and !$+$ == "false"