alert(\"zoo\">\"house\")
returns true
.
Could anyone explain me why?
strings are compared lexicographically.
Wiki - Lexicographical order
Because it does a lexical comparison, and z
is greater than h
(that is, the code unit for z
has a higher numeric value than the code unit for h
). If both strings started with the same character, the second character would be checked, and so on. Full details in turgid detail in the spec.