JavaScript标准库之 - Math

属性

Math.E

欧拉常数,也是自然对数的底数, 约等于 2.718.

Math.LN2

2的自然对数, 约等于0.693.

Math.LN10

10的自然对数, 约等于 2.303.

Math.LOG2E

以2为底E的对数, 约等于 1.443.

Math.LOG10E

以10为底E的对数, 约等于 0.434.

Math.PI

圆周率,一个圆的周长和直径之比,约等于 3.14159.

Math.SQRT1_2

1/2的平方根, 约等于 0.707.

Math.SQRT2

2的平方根,约等于 1.414.

Math.abs(x)

返回x的绝对值.

Math.acos(x)

返回x的反余弦值.

Math.acosh(x)

返回x的反双曲余弦值.

Math.asin(x)

返回x的反正弦值.

Math.asinh(x)

返回x的反双曲正弦值.

Math.atan(x)

以介于 -PI/2 与 PI/2 弧度之间的数值来返回 x 的反正切值.

Math.atanh(x)

返回 x 的反双曲正切值.

Math.atan2(x, y)

返回 y/x 的反正切值.

Math.cbrt(x)

返回x的立方根.

Math.ceil(x)

返回x向上取整后的值.

Math.clz32(x)

Returns the number of leading zeroes of a 32-bit integer.

Math.cos(x)

返回x的余弦值.

Math.cosh(x)

返回x的双曲余弦值.

Math.exp(x)

返回 Ex, 当x为参数, E 是欧拉常数 (2.718...), 自然对数的底.

Math.expm1(x)

返回 exp(x)-1 的值.

Math.floor(x)

返回小于x的最大整数。

Math.fround(x)

Returns the nearest single precision float representation of a number.

Math.hypot([x[,y[,…]]])

Returns the square root of the sum of squares of its arguments.

Math.imul(x)

Returns the result of a 32-bit integer multiplication.

Math.log(x)

Returns the natural logarithm (loge, also ln) of a number.

Math.log1p(x)

Returns the natural logarithm of 1 + x (loge, also ln) of a number.

Math.log10(x)

Returns the base 10 logarithm of x.

Math.log2(x)

Returns the base 2 logarithm of x.

Math.max([x[,y[,…]]])

返回0个到多个数值中最大值.

Math.min([x[,y[,…]]])

返回0个到多个数值中最小值.

Math.pow(x,y)

返回x的y次幂.

Math.random()

返回0到1之间的伪随机数.

Math.round(x)

返回四舍五入后的整数.

Math.sign(x)

返回x的符号函数, 判定x是正数,负数还是0.

Math.sin(x)

返回正弦值.

Math.sinh(x)

返回x的双曲正弦值.

Math.sqrt(x)

返回x的平方根.

Math.tan(x)

返回x的正切值.

Math.tanh(x)

返回x的双曲正切值.

Math.toSource()

返回字符串 "Math".

Math.trunc(x)

返回x的整数部分,去除小数.