Math 对象使用方法汇总
Math 对象 | 作用 |
---|---|
Math.abs( ) | 取绝对值 |
Math.min.apply( null , 数组名) | 找数组里的最小值 |
Math.max.apply(null , 数组名) | 找数组里的最大值 |
Math.floor ( -2.3 ) | 向下取整 -3 |
Math.ceil ( -2.3 ) | 向上取整 -2 |
Math.round() | 四舍五入 注意: 如 -2.5 结果是 -2 |
Math.random(没有参数) | 随机[0~1)之间的数 |
Math.pow ( 2 , 3 ) | 2 的 3 次方 |
Math.sqrt ( 9 ) | 开方结果 3 |
Matn.sin ( Math.PI / 3 ) | sin 60 |
Matn.cos ( Math.PI / 3 ) | cos 函数 |
Matn.tan ( Math.PI / 3 ) | tan 函数 |