'true' == true
Here's what happens here (according to the rules ):
- convert boolean to number (rule 7):
'true' == 1
- convert 'true' to Number (rule 5):
Number('true') == 1
- Number('true') NaN :
NaN == 1
- return false (rule 1.ci)
== really confusing, but it makes sense if you understand the rules:
- garbage is equal to garbage (undefined == null)
- no booleans (they are compared as numbers)
- if one of the parts is a number, compare the numeric
- if one of the parts is a string, compare as strings
- otherwise, a and b must be the same.
georg source share