We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1 + "1" 2 * "2" [1, 2] + [2, 1] "a" + + "b"
The text was updated successfully, but these errors were encountered:
答案: 11 4 1,22,1 aNaN
解析: 1 + "1" 加性操作符:如果只有一个操作数是字符串,则将另一个操作数转换为字符串,然后再将两个字符串拼接起来
所以值为:“11”
2 * "2" 乘性操作符:如果有一个操作数不是数值,则在后台调用 Number()将其转换为数值。
所以值为4
[1, 2] + [2, 1] Javascript中所有对象基本都是先调用valueOf方法,如果不是数值,再调用toString方法。
所以两个数组对象的toString方法相加,值为:"1,22,1"
"a" + + "b" 后边的“+”将作为一元操作符,如果操作数是字符串,将调用Number方法将该操作数转为数值,如果操作数无法转为数值,则为NaN。
所以值为:"aNaN"
以上均参考:《Javascript高级程序设计》
Sorry, something went wrong.
@qappleh 顶一个
No branches or pull requests
The text was updated successfully, but these errors were encountered: