|
|
@@ -0,0 +1,34 @@
|
|
|
+<!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>
|
|
|
+ // 内置对象 Math
|
|
|
+ // Math对象中包含了很多数学相关的属性和方法
|
|
|
+ // 属性会返回具体的一个值 而 方法会执行一些操作是一个函数
|
|
|
+ // 返回Pi值
|
|
|
+ console.log(Math.PI);
|
|
|
+ // 返回随机数
|
|
|
+ console.log(Math.random());
|
|
|
+ // 返回绝对值
|
|
|
+ console.log(Math.abs(-10));
|
|
|
+ // x的y次方
|
|
|
+ console.log(Math.pow(2,3));
|
|
|
+ // 返回最大值
|
|
|
+ console.log(Math.max(1,2,3,4,5));
|
|
|
+ // 返回最小值
|
|
|
+ console.log(Math.min(1,2,3,4,5));
|
|
|
+ // 返回四舍五入的整数
|
|
|
+ console.log(Math.round(3.54));
|
|
|
+ // 返回取整后的整数 直接去掉小数部分
|
|
|
+ console.log(Math.floor(3.14));
|
|
|
+ // 返回取整后的整数 去掉小数部分 只要包含小数无论数值多少都会向前进为
|
|
|
+ console.log(Math.ceil(3.14));
|
|
|
+
|
|
|
+ </script>
|
|
|
+</body>
|
|
|
+</html>
|