1234567891011121314151617181920212223242526272829 |
- <!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 xxx;
- 字面量:
- 1 2 5 8 true hello
- -->
- <script>
- document.write(Math.PI + '<br/>');//常量π
- document.write(Math.E);//常量
- console.log(Math.ceil(3.1456));//向上取整
- console.log(Math.floor(3.1456));//向下取整
- console.log(Math.abs(-8));//绝对值
- console.log(Math.round(10.28));//四舍五入
- console.log(Math.random() * 10);//随机数
- console.log(Math.pow(3,3));//x的y次幂
- console.log(Math.sqrt(16));//x的算数平方根
- // 固定范围内随机数
- // 固定范围内随机数取整(四舍五入)
- </script>
- </body>
- </html>
|