Click here to Skip to main content
16,016,501 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
C#
how 0==' ' in jquery? It Gives result as true if 0 and ' ' are compared


What I have tried:

how 0==' ' in jquery? It Gives result as true if 0 and ' ' are compared
Posted
Updated 3-Aug-16 12:13pm

1 solution

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
JavaScript
"" == 0
is true.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900