----- 随机数 -----


 Math.random() 
随机类型:浮点数
范围:[ 0, 1 )
示例
const a = Math.random();
console.log(a);  //0<= a <1
 
//指定范围(浮点数)
function fn(min, max){
    return Math.random() * (max - min) + min;
}
const a = fn(10, 20);
console.log(a);  //10<= a <20
 
//指定范围(整数)
function fn(min, max){
    return Math.floor(Math.random() * (max - min) + min);//不包含 max
    return Math.floor(Math.random() * (max - min + 1) + min);//包含 max
}
const a = fn(10, 20);
console.log(a);  //10<= a <20
 
//随机排列



----- 运算 -----


 Math 对象方法 
示例
//四舍五入
Math.ceil(x);  //向上取整
Math.floor(x);  //向下取整
Math.trunc(x);  //舍去小数位(在正数时相当于向下取整,在负数时相当于向上取整)
Math.round(x);  //四舍五入
 
//三角函数
Math.cos(x);  //返回 x 的余弦值(x 范围: -1.0 ~ 1.0)
Math.acos(x);  //返回 x 的反余弦值
Math.sin(x);  //返回 x 的正弦值
Math.asin(x);  //返回 x 的反正弦值(x 范围: -1.0 ~ 1.0)
Math.tan(x);  //返回角的正切值
Math.atan(x);  //以介于 -PI/2 与 PI/2 弧度之间的数值来返回 x 的反正切值
Math.atan2(y,x);  //返回从 x 轴到点 (x,y) 的角度(介于 -PI/2 与 PI/2 弧度之间)
Math.tanh(y,x);  //返回 x 的双曲正切函数值
 
//次方、幂
Math.exp(x);  //返回 e 的 x 次方
Math.log(x);  //返回 x 的自然对数(底为e)
Math.LOG10E;  //返回 10 为底,e 的对数 = log(10的e次方)
Math.LOG2E;  //返回 2 为底,e 的对数 = log(2的e次方)
Math.LN10;  //返回 e 为底,10 的对数 = log(e的10次方)
Math.LN2;  //返回 e 为底,2 的对数 = log(e的2次方)
Math.pow(x, y);  //返回 x 的 y 次方
Math.sqrt(x);  //返回 x 的平方根
Math.SQRT2;  //返回 2 的平方根
Math.SQRT1_2;  //返回 2 的平方根的倒数
 
//其他
Math.abs(x);  //返回 x 的绝对值
Math.max(x, y, z);  //返回最大值
Math.min(x, y, z);  //返回最小值
Math.round();  //返回0~1之间随机数
Math.PI;  //返回圆周率
Math.E;  //返回 e