JavaScript Map函数min,max,以及属性
Math.min() 和 Math.max()
Math.min() 和 Math.max() 可用于查找参数列表中的最低或最高值:
实例
Math.min(0, 450, 35, 10, -8, -300, -78); // 返回 -300
实例
Math.max(0, 450, 35, 10, -8, -300, -78); // 返回 450
Math.random()
Math.random() 返回介于 0(包括) 与 1(不包括) 之间的随机数:
实例
Math.random(); // 返回随机数
Math 属性(常量)
JavaScript 提供了可由 Math 对象访问的 8 个数学常量:
实例
Math.E // 返回欧拉指数(Euler's number)
Math.PI // 返回圆周率(PI)
Math.SQRT2 // 返回 2 的平方根
Math.SQRT1_2 // 返回 1/2 的平方根
Math.LN2 // 返回 2 的自然对数
Math.LN10 // 返回 10 的自然对数
Math.LOG2E // 返回以 2 为底的 e 的对数(约等于 1.414)
Math.LOG10E // 返回以 10 为底的 e 的对数(约等于0.434)
如需转载,请注明文章出处和来源网址:http://www.divcss5.com/html/h64432.shtml