Reputation: 2745
This expression:
'33.33' > '100.00'
return true
. Why?
If it work like:
+'33.33' > +'100.00'
it must return false
because 33.33 < 100;
If like:
'33.33'.length > '100.00'.length
then false
, because 5 < 6;
I'm really interested know, how it work in the first case;
Upvotes: 1
Views: 740
Reputation: 2745
OK. I feel ashamed. While I wrote & formated this post, I find the answer.
For string compare JS use Lexicographical order; So, in this case we have just:
'3' > '1'
and it's really true
.
Maybe it would be interesting for someone.
Upvotes: 1