Skip to content
New issue

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

true + true == true 的结果是什么?为什么? #40

Open
CodeRookie262 opened this issue Feb 23, 2021 · 1 comment
Open

true + true == true 的结果是什么?为什么? #40

CodeRookie262 opened this issue Feb 23, 2021 · 1 comment

Comments

@CodeRookie262
Copy link
Owner

No description provided.

@CodeRookie262 CodeRookie262 changed the title true + true == true 的结果是什么?为什么 true + true == true 的结果是什么?为什么? Feb 23, 2021
@CodeRookie262
Copy link
Owner Author

除了字符数,数值外的类型在加法运算中都会进行隐式类型转换为数值,所以 true 最终会变为 1,即 2 == true;
在数值类型与其他类型的比较之间会把非数值类型隐式类型转换为数值,2 == 1,故最终结果为 false。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant