with javascript when you compare 2 strings what are you comparing exactly
return "hello" > "hola"
this will return false, why ?
with javascript when you compare 2 strings what are you comparing exactly
return "hello" > "hola"
this will return false, why ?
The strings are compared character-by-character (h vs h), then (e vs o) until either one (or both) of the strings ends, or you get an inequality. In this case 'e' is less than 'o'.
Every character is represented as a number.
The comparison in javascript strings first compares characters one by one from the beginning. An string is bigger than another when the same index characters of the first different character in both strings is bigger than another.
"hello" > "hola"
"h" == "h"
"e" != "o" --> "e" < "o"
this is why the result is false;