** Math** is a built-in object that has properties and methods for mathematical constants and functions. Not a function object.

Unlike the other global objects, `Math`

is not a constructor. All properties and methods of `Math`

are static. You refer to the constant pi as `Math.PI`

and you call the sine function as `Math.sin(x)`

, where `x`

is the method's argument. Constants are defined with the full precision of real numbers in JavaScript.

`Math.E`

- Euler's constant and the base of natural logarithms, approximately 2.718.
`Math.LN2`

- Natural logarithm of 2, approximately 0.693.
`Math.LN10`

- Natural logarithm of 10, approximately 2.303.
`Math.LOG2E`

- Base 2 logarithm of E, approximately 1.443.
`Math.LOG10E`

- Base 10 logarithm of E, approximately 0.434.
`Math.PI`

- Ratio of the circumference of a circle to its diameter, approximately 3.14159.
`Math.SQRT1_2`

- Square root of 1/2; equivalently, 1 over the square root of 2, approximately 0.707.
`Math.SQRT2`

- Square root of 2, approximately 1.414.

Note that the trigonometric functions (`sin()`

, `cos()`

, `tan()`

, `asin()`

, `acos()`

, `atan()`

, `atan2()`

) expect or return angles in radians. To convert radians to degrees, divide by `(Math.PI / 180)`

, and multiply by this to convert the other way.

Note that a lot of the math functions have a precision that's implementation-dependent. This means that different browsers can give a different result, and even the same JS engine on a different OS or architecture can give different results.

`Math.abs(x)`

- Returns the absolute value of a number.
`Math.acos(x)`

- Returns the arccosine of a number.
`Math.asin(x)`

- Returns the arcsine of a number.
`Math.atan(x)`

- Returns the arctangent of a number.
`Math.atan2(y, x)`

- Returns the arctangent of the quotient of its arguments.
`Math.ceil(x)`

- Returns the smallest integer greater than or equal to a number.
`Math.cos(x)`

- Returns the cosine of a number.
`Math.exp(x)`

- Returns E
^{x}, where`x`is the argument, and E is Euler's constant (2.718…), the base of the natural logarithm. `Math.floor(x)`

- Returns the largest integer less than or equal to a number.
`Math.log(x)`

- Returns the natural logarithm (log
_{e}, also ln) of a number. `Math.max([x[, y[, …]]])`

- Returns the largest of zero or more numbers.
`Math.min([x[, y[, …]]])`

- Returns the smallest of zero or more numbers.
`Math.pow(x, y)`

- Returns base to the exponent power, that is,
`base`

.^{exponent} `Math.random()`

- Returns a pseudo-random number between 0 and 1.
`Math.round(x)`

- Returns the value of a number rounded to the nearest integer.
`Math.sin(x)`

- Returns the sine of a number.
`Math.sqrt(x)`

- Returns the positive square root of a number.
`Math.tan(x)`

- Returns the tangent of a number.
`Math.toSource()`

- Returns the string
`"Math"`

.

Created by Mozilla Contributors and licensed under CC-BY-SA 2.5