Why is one string greater than the other when comparing strings in JavaScript?

后端 未结 4 1119
鱼传尺愫
鱼传尺愫 2020-11-22 09:48

I see this code from a book:

var a = \"one\";
var b = \"four\";
a>b; // will return true

but it doesn\'t mention why \"one\" is bigger t

4条回答
  •  迷失自我
    2020-11-22 09:56

    Javascript uses Lexicographical order for the > operator. 'f' proceeds 'o' so the comparison "one" > "four" returns true

提交回复
热议问题