1.返回估算值(四舍五入):document.write(Math.round())
2.返回0-1之间的随机数:document.write(Math.random())
3.返回两个数间的较大值和较小值:document.write(Math.max(a,b)) document.write(Math.min(a,b))
4.JavaScript 提供 8 种可被 Math 对象访问的算数值:
- 常数
- 圆周率
- 2 的平方根
- 1/2 的平方根
- 2 的自然对数
- 10 的自然对数
- 以 2 为底的 e 的对数
- 以 10 为底的 e 的对数
这是在 Javascript 中使用这些值的方法:(与上面的算数值一一对应)
- Math.E
- Math.PI
- Math.SQRT2
- Math.SQRT1_2
- Math.LN2
- Math.LN10
- Math.LOG2E
- Math.LOG10E