what's the result of 1 + undefined

前端 未结 3 1183
天涯浪人
天涯浪人 2020-12-17 01:11
1 + undefined = ?  
  1. first, String(undefined) get string \"undefined\"
  2. second, 1 + \"undefined\" = \"1undefined\"

what

3条回答
  •  北海茫月
    2020-12-17 02:00

    You expect a string concatenation, but this will only happen if you have at least one string. And in your example nothing is a string. 1 is not a string and undefined is not a string.

提交回复
热议问题