Why false==="0" is false ? | SoloLearn: Learn to code for FREE!


Why false==="0" is false ?

Why false==="0" is false?

8/9/2017 9:44:40 PM

Vincent Piat

10 Answers

New Answer


console.log (typeof false) console.log (typeof 0) console.log (typeof "0") #Output Boolean Integer String All may be worth zero, but === compares not only the value but also the type, so if you compare any of them, the result will be false because they are of different type


=== checks value and data type. 0 === 0 returns true 0 === "0" returns false


Paul, yes, that should be.


I'm not sure which language this is, but in most languages, False == 0, not False == "0". The difference is that in the correct way, 0 is an integer, but when it's in quotation marks, then it is a string. The same goes for True == 1 and not True == "1". Although, I'm not sure in my answer because you haven't provided enough info.


okay, so that is why! i mean i think that with == we have a conversion from string to int or even to bool directly and it returns true whereas === will eventually check if "0" is of type bool, right?


what language do you use?


i write the code in js: alert (false=="0") and the answer is true but for alert (false==="0") the answer become false do you understand why?


there is such thing as ===? what does it stands for? == is ok tho, but dunno why it accepts 0 as strung and return true


Thanks I understand now