• js的运算符学习笔记


    js的运算符

    image


    1、加号运算

    <!DOCTYPE html>
    <html lange = "en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
    </head>
    <body>
        <h1>js运算</h1>
        <h2>加号运算</h2>
        <script type="text/javascript">
            var a = 1 + 1 + "a" + ( 1 + 2 );
            document.write(a);
    
        </script>
    
    
    
    
    </body>

    运行结果为:注意运算顺序

    image

    减号运算和称号运算  略

    除号运算

    <!DOCTYPE html>
    <html lange = "en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
    </head>
    <body>
        <h1>js运算</h1>
        <h2>加号运算</h2>
        <script type="text/javascript">
            var a = 1 + 1 + "a" + ( 1 + 2 );
            document.write(a);
    
        </script>
    
        <h2>除号运算</h2>
        <a>     1/0 是无穷 a = 1 / 0 =
        <script type="text/javascript">
            var a = 1 / 0;
            document.write(a);
    
        </script>
    
        </a>
    
        <br/>
        <a>     0/0 得到的不是数 a = 10 / 0 =
        <script type="text/javascript">
            var a = 0 / 0;
            document.write(a);
        </script>
    
        </a>
    
    </body>


    结果为

    image


    取余运算 %(略)


    ++  --

    <!DOCTYPE html>
    <html lange = "en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
    </head>
    <body>
        <h1>js运算</h1>
        <h2>加号运算</h2>
        <script type="text/javascript">
            var a = 1 + 1 + "a" + ( 1 + 2 );
            document.write(a);
    
        </script>
    
        <h2>除号运算</h2>
        <a>     1/0 是无穷 a = 1 / 0 =
        <script type="text/javascript">
            var a = 1 / 0;
            document.write(a);
    
        </script>
    
        </a>
    
        <br/>
        <a>     0/0 得到的不是数 a = 10 / 0 =
        <script type="text/javascript">
            var a = 0 / 0;
            document.write(a);
        </script>
    
        </a>
    
        <br/>
        <a>      b = a++ 
        <script type="text/javascript">
            var a = 10;
            b = a++
            document.write("a = " + a + " b = " + b);
        </script>
    
        </a>
        <br/>
        <a>     b = ++a    
        <script type="text/javascript">
            var a = 10;
            b = ++a
            document.write("a = "  + a + " b = " + b);
        </script>
    
        </a>
    </body>

    赋值运算  从右向左  ,计算顺序  从左至右

    image


    a+=10  等同于 a+=10

    a += 10 +1 为 a+10

    结果为21

    人在中年,一事无成,瞎学
  • 相关阅读:
    Windows Azure Cloud Service (6) Reboot and Reimage
    Windows Azure Platform Introduction (7) Windows Azure Host OS 和 Guest OS
    Nod32的内网升级方案
    32位色
    ASP.NET 2.0 的内部变化
    关于Nod的离线升级方案
    光、色、补色
    解决迅雷的“重复任务提示”
    Nod32Viewer不能取得最新的镜像包的问题
    火车头实在是太好玩了
  • 原文地址:https://www.cnblogs.com/jilingxf/p/13820567.html
Copyright © 2020-2023  润新知