且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

javascript - var a = "23" < "3",a为什么是boolean值true?

更新时间:2022-10-23 15:02:36

https://developer.mozilla.org...

C developers have the strcmp() function for comparing strings. In JavaScript, you just use the less-than and greater-than operators:

就是strcmp的规则吧....

两个字符串自左向右逐个字符相比(按ASCII值大小相比较),
2<3