JavaScript Math 对象

// 返回算术常量 e,即自然对数的底数(约等于2.718)。
Math.E; // 2.718281828459045
// 返回圆周率(约等于3.14159)。
Math.PI; // 3.141592653589793
// 返回最低值。
Math.min(1, 2, 3, 4, 5, 6); // 1
// 返回最高值。
Math.max(1, 2, 3, 4, 5, 6); // 6
// 对数进行上舍入。
Math.ceil(25.1); // 26
// 对数进行下舍入。
Math.floor(25.9); // 25
// 把数四舍五入为最接近的整数。
Math.round(25.5); // 26
Math.round(25.4); // 25
// 返回 0 ~ 1 之间的随机数,不包含0和1。
Math.random(); // 0.4998697099704563
Math.random(); // 0.040587644960129676
Math.random(); // 0.32775131649736466
原文地址:https://www.cnblogs.com/pumushan/p/6731802.html