JavaScript中字符串的比较
时间:2014-12-31 18:18:58
收藏:0
阅读:144
有时候,很多方法都不行,比如==.equals都不行 ,那怎么办呢?
用localeCompare方法可以。
使用方法:
string_a.localeCompare(string_b) 方法去做;它会返回3个值
0:字符串相等
-1:字符串string_a<string_b.
1:字符串string_a>string_b
大家以后就可以使用正确的方法比较字符串了
原文:http://www.cnblogs.com/lixiongjun/p/4196138.html
评论(0)