| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <script>
- var a = 1;
- var b = 2;
- // 加法
- console.log(a+b);
- // 由于计算机计算精度问题 0.1 + 0.2 不等于0.3
- console.log(0.1+0.2);
- // 减法
- console.log(2-1);
- // 乘法
- console.log(2*2);
- // 除法
- console.log(4/2);
- // 取余
- console.log(5%2);
- // 括号
- console.log((2+1)*2);
- // NaN not a number 当我们看到这个类型表示数学运算中出现了非数值类型 (加法除外)
- // 除了加法其他的数学运算只要有一个操作数不是数值型那么就返回一个NaN
- console.log("a" * 2);
- // 如果参与数学运算的操作数中有一个是字符串 如果这个字符串是一个数字那么可以把它转换成数值型运算
- console.log("6" * 2);
-
-
-
-
-
-
-
-
- </script>
- </body>
- </html>
|