Possible Duplicate:
Can somebody explain this Javascript method ?
(x = [].reverse)() === window // true
Any idea why?
(x=[].reverse)() === window // true
Didn't understand this one at first, but I guess it is easy: first x becomes the reverse function of arrays, then it is called with
this === window
. So it amounts towindow.reverse()
. Just looked it up, and reverse() works in place, sowindow.reverse() === window
- although it is potentially different from before.
I got this answer from this link
http://news.ycombinator.com/item?id=1122004
精彩评论