圆周率
Math.PI; // 返回 3.141592653589793
Math.random() 返回介于 0(包括) 与 1(不包括) 之间的随机数:
Math.random(); // 返回随机数
Math.round() 四舍五入 返回 整数
Math.round(6.8); // 返回 7
Math.round(2.3); // 返回 2
Math.ceil() 向上取整
Math.ceil(6.4); // 返回 7
Math.floor() 向下取整
Math.floor(Math.random()*10) //所得到的的是0-10之间的随机数,不包括 10 0-9
Math.floor(Math.random()*10+1) //所得到的的是1-10之间的随机数,包括 10 1-10,如果要2-10之间则将括号内1改为2 即可
Math.round( Math.random()*10 ) // 0-10的随机数Math.floor(Math.random() * 11); // 返回 0 至 10 的随机数
Math.floor(2.7); // 返回 2
Math.min() 查找参数列表中的最低值
Math.min(0, 450, 35, 10, -8, -300, -78); // 返回 -300
Math.max() 查找参数列表中的最高值:
Math.max(0, 450, 35, 10, -8, -300, -78); // 返回 450