为什么 {} + {} NaN 只在客户端?为什么不在 Node.js?
while 是空字符串, 是 和 是 。为什么是NaN?[] + [][] + {}"[object Object]"{} + []0{} + {}
> {} + {}
  NaN
我的问题不是为什么是,这部分已经有了答案。({} + {}).toString()"[object Object][object Object]"NaN.toString()"NaN"
我的问题是为什么这只发生在客户端?在服务器端(节点.js)是 。{} + {}"[object Object][object Object]"
> {} + {}
'[object Object][object Object]'
总结:
在客户端:
 [] + []              // Returns ""
 [] + {}              // Returns "[object Object]"
 {} + []              // Returns 0
 {} + {}              // Returns NaN
 NaN.toString()       // Returns "NaN"
 ({} + {}).toString() // Returns "[object Object][object Object]"
 var a = {} + {};     // 'a' will be "[object Object][object Object]"
在节点中.js:
 [] + []   // Returns "" (like on the client)
 [] + {}   // Returns "[object Object]" (like on the client)
 {} + []   // Returns "[object Object]" (not like on the client)
 {} + {}   // Returns "[object Object][object Object]" (not like on the client)