JS-比较操作

数字与字符比较

    var result1 = 5 > 3;    //true
    var result2 = 5 < 3;    //false
    var result3 = "Brick" < "alphabet";  //true
    var result4 = "Brick".toLowerCase() < "alphabet".toLowerCase();  //false
    var result5 = "23" < "3";  //true
    var result6 = "23" < 3;    //false
    var result7 = "a" < 3;    //false because "a" becomes NaN
    var result8 = NaN < 3;    //false
    var result9 = NaN >= 3;   //false
    var result9 = NaN >= "3";   //false

如果同为数字则直接比较大小
如果同为字符,则会转换第一个字符为 ascii 对应的数字,再比较
如果有一个为字符,一个为数字,则字符转换为“NaN”,但“NaN”和任何数字或字符比较都会是 false