22.赋值运算符

<!DOCTYPE html>
<html>
     <head>
         <meta charset=”UTF-8″>
         <title></title>
         <script type=”text/javascript”>
             /*
              * =
              *     可以将符号右侧的值赋值给符号左侧的变量
              * +=
              *     a += 5 等价于 a = a + 5
              * -=
              *     a -= 5 等价于 a = a – 5
              * *=
              *     a *= 5 等价于 a = a * 5
              * /=
              *     a /= 5 等价于 a = a / 5
              * %=
              *     a %= 5 等价于 a = a % 5
              *    
              */
             var a = 10;
            
             //a = a + 5;
             //a += 5;
            
             //a -= 5;
            
             //a *= 5;
            
             // a = a%3;
             a %= 3;
            
             console.log(“a = “+a);
            
         </script>
     </head>
     <body>
     </body>
</html>

打赏

发布者

张 大鹏

北京理想国惠玩科技有限公司CEO

发表评论

电子邮件地址不会被公开。 必填项已用*标注