I am still learning the basics of javaScript and I don't understand why this happens.
Having type coercion false == "false"
would be converted into:
false == false //true
or
"false" == "false" //true
So, why false == "false"
is false?
javascript
I am still learning the basics of javaScript and I don't understand why this happens.
Having type coercion false == "false"
would be converted into:
false == false //true
or
"false" == "false" //true
So, why false == "false"
is false?
Best Answer
You've misunderstood the type conversion rules.
false
doesn't get converted to a string before comparison.false
is converted to a number, which gives:… then …
…
"false"
is converted to a number, which gives:… which is false.