12345678910111213141516171819202122232425262728293031 |
- <!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>
- <!--
- var 定义变量
- var a = 1;
- 字面量
- 1 2 3 4 6 true
- -->
- <script>
- document.write(Math.PI+'<br>'); // Math.PI => Π 常量
- document.write(Math.E);// 常量 固定值
- console.log(Math.ceil(2.167)); // 向上取整
- console.log(Math.floor(93.1)); // 向下取整
- console.log(Math.abs(-90)); // 绝对值
- console.log(Math.round(2.1)); //四舍五入
- console.log(Math.random()*10); // 随机数
- // 固定范围内随机数 Math.random()*(y-x)+x
- console.log(Math.random()*(4)+1)
- // 固定范围内随机数 Math.round(Math.random()*(y-x)+x)
- console.log(Math.round(Math.random()*(9)+11));
- console.log(Math.pow(3,6));//获取x的y次幂
- console.log(Math.sqrt(81)); //获取x的算术平方根
- </script>
- </body>
- </html>
|