• javascript 中的比较大小,兼 typeof()用法


    javascript中的排序: 1.不同类型 比 类型 (字符串 > 数字)   2.同类型:(字符串  比 按字母顺序 )(数字 比 大小)

    测试:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Javascript typeof</title>
    </head>
    <body>
    
    <script type="text/javascript">
        var a = "11111";
        var b = "22222";
        var c = 22222;
        var str = 'string';
    
        var s1 = "abb";
        var s2 = "abcd";
        var s3 = "-";
        
        console.log('typeof', typeof a);
        console.log('typeof b', typeof b);  
        console.log('typeof c', typeof c);
        console.log('typeof b > typeof c', typeof b > typeof c);
        console.log('typeof a === typeof b', typeof a === typeof b);
        console.log('typeof a === typeof c', typeof a === typeof c);
        console.log('typeof a === str', typeof a === str);
        console.log('a-b', a-b);
        console.log('a-c', a-c);
        console.log('s1-s2', s1-s2);
        console.log('s1>s2 ?', s1>s2);
        console.log('s1<s2 ?', s1<s2);
    
        console.log('parseInt(s1)', parseInt(s3));
        console.log('parseFloat(s1)', parseFloat(s3));
        console.log('Number(s1)', Number(s3));
    
        console.log('a-0', a-0);
        console.log('s3-0', s3-0);
    
    </script>
        
    </body>
    </html>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Javascript typeof</title>
    </head>
    <body>
    
    <script type="text/javascript">
        var a = "11111";
        var b = "22222";
        var c = 22222;
        var str = 'string';
    
        var s1 = "abb";
        var s2 = "abcd";
        var s3 = "-";
        
        console.log('typeof', typeof a);
        console.log('typeof b', typeof b);  
        console.log('typeof c', typeof c);
        console.log('typeof b > typeof c', typeof b > typeof c);
        console.log('typeof a === typeof b', typeof a === typeof b);
        console.log('typeof a === typeof c', typeof a === typeof c);
        console.log('typeof a === str', typeof a === str);
        console.log('a-b', a-b);
        console.log('a-c', a-c);
        console.log('s1-s2', s1-s2);
        console.log('s1>s2 ?', s1>s2);
        console.log('s1<s2 ?', s1<s2);
    
        console.log('parseInt(s1)', parseInt(s3));
        console.log('parseFloat(s1)', parseFloat(s3));
        console.log('Number(s1)', Number(s3));
    
        console.log('a-0', a-0);
        console.log('s3-0', s3-0);
    
    </script>
        
    </body>
    </html>

    输出结果:

  • 相关阅读:
    玩个JAVA爬虫,没想玩大
    利用 Ruoyi 开发自己的业务管理系统__测试结构完成
    Vmware 和 VisualSVN-Server端口冲突
    Ruoyi的确不错,不知后续能否坚持 允许商用
    张勇:海底捞店长最高年薪600万!
    自己安装windows版本的Flink
    windows平台上运行Flink_转载于CSDN
    洛谷P3980 [NOI2008]志愿者招募
    线段树优化连边
    [HNOI2013]题解
  • 原文地址:https://www.cnblogs.com/cnblogs-jcy/p/6605329.html
Copyright © 2020-2023  润新知