Built-In Mathematical Calculations

Math is a built-in object with properties and methods for mathematical constants and functions. It is not a function object. Math works with the Number type. Math functions are all static, so each starts with Math.myfunctioncallhere(). Math.PI and Math.random() are two Math functions used a lot when doing calculations.

Static methods

Math.abs()

Returns the absolute value of x.

Math.acos()

Returns the arccosine of x.

Math.acosh()

Returns the hyperbolic arccosine of x.

Math.asin()

Returns the arcsine of x.

Math.asinh()

Returns the hyperbolic arcsine of a number.

Math.atan()

Returns the arctangent of x.

Math.atan2()

Returns the arctangent of the quotient of its arguments.

Math.atanh()

Returns the hyperbolic arctangent of x.

Math.cbrt()

Returns the cube root of x.

Math.ceil()

Returns the smallest integer greater than or equal to x.

Math.clz32()

Returns the number of leading zero bits of the 32-bit integer x.

Math.cos()

Returns the cosine of x.

Math.cosh()

Returns the hyperbolic cosine of x.

Math.exp()

Returns ex, where x is the argument, and e is Euler's number (2.718…, the base of the natural logarithm).

Math.expm1()

Returns subtracting 1 from exp(x).

Math.floor()

Returns the largest integer less than or equal to x.

Math.fround()

Returns the nearest single precision float representation of x.

Math.hypot()

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

Math.imul()

Returns the result of the 32-bit integer multiplication of x and y.

Math.log()

Returns the natural logarithm (㏒e; also, ㏑) of x.

Math.log10()

Returns the base-10 logarithm of x.

Math.log1p()

Returns the natural logarithm (㏒e; also ㏑) of 1 + x for the number x.

Math.log2()

Returns the base-2 logarithm of x.

Math.max()

Returns the largest of zero or more numbers.

Math.min()

Returns the smallest of zero or more numbers.

Math.pow()

Returns base x to the exponent power y (that is, xy).

Math.random()

Returns a pseudo-random number between 0 and 1.

Math.round()

Returns the value of the number x rounded to the nearest integer.

Math.sign()

Returns the sign of the x, indicating whether x is positive, negative, or zero.

Math.sin()

Returns the sine of x.

Math.sinh()

Returns the hyperbolic sine of x.

Math.sqrt()

Returns the positive square root of x.

Math.tan()

Returns the tangent of x.

Math.tanh()

Returns the hyperbolic tangent of x.

Math.trunc()

Returns the integer portion of x, removing any fractional digits.