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
总结一下就是: 能转数字的最后都转成数字,对象用 ToPrimitive 转成原始类型,两边进行比较。 但是注意,按照上面的规则,undefined 和 null 只有在这俩比较的时候,undefined == null // true,不会变成 0。
undefined == null // true
undefined 和 null 在进行相等判断的时候,不会进行类型转换!
所以,null == 0 和 undefined == 0 都是 false。
null == 0
undefined == 0
false
进行大于等于比较的时候,undefined 和 null 进行了类型转换,变成了 0,所以 null >= 0 是 true。
null >= 0
null > 0 是 false,同理,null 转化为了 0,0 > 0 是 false
null > 0
The text was updated successfully, but these errors were encountered:
No branches or pull requests
== 的比较过程
总结一下就是:
能转数字的最后都转成数字,对象用 ToPrimitive 转成原始类型,两边进行比较。
但是注意,按照上面的规则,undefined 和 null 只有在这俩比较的时候,
undefined == null // true
,不会变成 0。undefined 和 null 在进行相等判断的时候,不会进行类型转换!
所以,
null == 0
和undefined == 0
都是false
。>=
进行大于等于比较的时候,undefined 和 null 进行了类型转换,变成了 0,所以
null >= 0
是 true。null > 0
是 false,同理,null 转化为了 0,0 > 0 是 falseThe text was updated successfully, but these errors were encountered: