标签:
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="UTF-8">
5 <title></title>
6 </head>
7 <body>
8 </body>
9 <script type="text/javascript">
10 //算术运算符 + - * / %
11 var result = 5*(2 + 4);
12 alert(result);
13
14 //在 js 里面除数为0,并不会报错
15 var result = 5 / 0;
16 alert(result);
17 //取余
18 //5 % 13 只要大于5,余数都为5
19 //5 % 6 余数为5
20 //5 % 2 余数为1
21 //5 % 5 余数为0
22 var result = 5 % 13;
23 alert(result);
24
25 //比较运算符号 > >= < <= != ==
26 var number1 = 5;
27 var number2 = 3;
28 //true
29 var result1 = number1 >= number2;
30
31
32 //true
33 var result2 = number1 != number2;
34
35
36 //false
37 var result3 = number1 == number2;
38
39 // 优先级: 算术运算符>比较运算符>赋值运算符
40 var result = number1 < number2 + 10;
41 alert(result);
42
43 </script>
44
45 </html>
标签:
原文地址:http://www.cnblogs.com/PowellZhao/p/5537607.html