Why is 0 == "" true in JavaScript? I have found a similar post here, but why is a number 0 similar an empty string? Of course, 0 === "" is false.
Why is 0 == true in JavaScript? I have found a similar post here
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The left operand is of the type Number.
The right operand is of the type String.
In this case, the right operand is coerced to the type Number:
which results in
From the Abstract Equality Comparison Algorithm (number 4):
Source: http://es5.github.com/#x11.9.3