Appearance
js
Math.PI // 圆周率
Math.abs() // 数字绝对值
Math.abs(10) // 10
Math.abs(0) // 0
Math.abs(-10) // 10
Math.ceil() / Math.floor() // 数组向上/下取整
Math.ceil(12) // 12
Math.ceil(12.01) // 13
Math.ceil(12.99) // 13
Math.ceil(-12.01) // -12
Math.ceil(-12.01) // =12
Math.floor(12) // 12
Math.floor(12.01) // 12
Math.floor(12.99) // 12
Math.floor(-12.01) // -13
Math.floor(-12.01) // -13
Math.round() // 四舍五入
Math.round(12) // 12
Math.round(12.01) // 12 正数中,5及5以上是进位
Math.round(12.5) // 13
Math.round(12.51) // 13
Math.round(-12) // 12
Math.round(-12.01) // -12 负数中,5及5以下是舍弃
Math.round(-12.49) // -12
Math.round(-12.5) // -12
Math.round(-12.51) // -13
Math.max(N1, N2, ...) / Math.min(N1, N2, ...) // 获取最大/最小值
Math.pow() // 指数运算
Math.pow(2, 10) // 1024
Math.pow(2, -2) // 0.25
Math.sqrt() // 开方
Math.Random() // 生成(0, 1]之间的数
[1, n]: Math.floor(Math.Random() * n) + 1
[0, n]: Math.floor(Math.random() * n + 1)