开发者

Why does this expression return true? [duplicate]

开发者 https://www.devze.com 2022-12-20 15:01 出处:网络
This question already has an answer here: 开发者_运维技巧 Closed 12 years ago. Possible Duplicate:
This question already has an answer here: 开发者_运维技巧 Closed 12 years ago.

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 to window.reverse(). Just looked it up, and reverse() works in place, so window.reverse() === window - although it is potentially different from before.

I got this answer from this link

http://news.ycombinator.com/item?id=1122004

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号