如何在jquery中0 ==''?如果比较0和',则结果为真 [英] How 0==' ' in jquery? It gives result as true if 0 and ' ' are compared

查看:120
本文介绍了如何在jquery中0 ==''?如果比较0和',则结果为真的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

how 0==' ' in jquery? It Gives result as true if 0 and ' ' are compared





我尝试过:



如何0 = =''在jquery中?如果0和''被比较,它给出结果为真



What I have tried:

how 0==' ' in jquery? It Gives result as true if 0 and ' ' are compared

推荐答案

你应该在编写代码之前学习Java脚本,因为它们是很多像这样的人应该知道的。否则,您可能会写错误的代码而不理解原因。


=== 应该在需要时使用确保你在两边都有相同的类型。



在下面的网站上,有一个表格显示了一些比较的结果:



平等比较和相同 - JavaScript MDN [ ^ ]



它清楚地表明
You should learn Java script before writing code as they are many subtilities like this one that one should be aware. Otherwise, you might write buggy code not understanding why.

=== should be used instead when you want to ensure that you have same type on both side.

On the following site, there is a table that show the result of some comparison:

Equality comparisons and sameness - JavaScript | MDN[^]

It clearly show that
"" == 0

为真。


这篇关于如何在jquery中0 ==''?如果比较0和',则结果为真的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆