+ 6
Why false==="0" is false ?
Why false==="0" is false?
10 Respuestas
+ 10
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
+ 8
=== checks value and data type.
0 === 0 returns true
0 === "0" returns false
+ 7
Paul, yes, that should be.
+ 6
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.
+ 4
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?
+ 3
what language do you use?
+ 3
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?
+ 3
there is such thing as ===? what does it stands for? == is ok tho, but dunno why it accepts 0 as strung and return true
+ 3
Thanks I understand now
+ 2
javascript