Possible Duplicate:
What is the explanation for these bizarre JavaScript behaviours mentioned in the 'Wat' talk for CodeMash 2012?
What is the explanation for these bizarre JavaScript behaviours mentioned in the 'Wat' talk for CodeMash 2012?
I know that when []
is coerced to a string it returns the empty string (""
), and when {}
is coerced to a string it returns "[object Object]"
.
When I run [] + {}
in my browser's Javascript console, it returns "[object Object]"
, which is not what I expected.
>> [] + {}
"[object Object]"
但是当我运行{} + []
时,它返回了一个完全意料之外的值:
>> {} + []
0
是什么导致它返回0
?