Math Object (JavaScript)

An intrinsic object that provides basic mathematics functionality and constants.

Syntax


Math.[{property | method}]  

Parameters

property
Required. Name of one of the properties of the Math. object.

method
Required. Name of one of the methods of the Math. object.

Remarks

The Math object cannot be created using the new operator, and gives an error if you attempt to do so. The scripting engine creates it when the engine is loaded. All of its methods and properties are available to your script at all times.

Requirements

The Math object was introduced in Internet Explorer before Internet Explorer 6.

Constants

The following table lists the constants of the Math object.

Constant Description
Math.E Constant The mathematical constant e. This is Euler's number, the base of natural logarithms.
Math.LN2 Constant The natural logarithm of 2.
Math.LN10 Constant The natural logarithm of 10.
Math.LOG2E Constant The base-2 logarithm of e.
Math.LOG10E Constant The base-10 logarithm of e.
Math.PI Constant Pi. This is the ratio of the circumference of a circle to its diameter.
Math.SQRT1_2 Constant The square root of 0.5, or, equivalently, one divided by the square root of 2.
Math.SQRT2 Constant The square root of 2.

Functions

The following table lists the functions of the Math object.

Function Description
Math.abs Function Returns the absolute value of a number.
Math.acos Function Returns the arccosine of a number.
Math.acosh Function Returns the hyperbolic arccosine (or inverse hyperbolic cosine) of a number.
Math.asin Function Returns the arcsine of a number.
Math.asinh Function Returns the inverse hyperbolic sine of a number.
Math.atan Function Returns the arctangent of a number.
Math.atan2 Function Returns the angle (in radians) from the X axis to a point represented by the supplied y and x coordinates.
Math.atanh Function Returns the inverse hyperbolic tangent of a number.
Math.ceil Function Returns the smallest integer that is greater than or equal to the supplied numeric expression.
Math.cos Function Returns the cosine of a number.
Math.cosh Function Returns the hyperbolic cosine of a number.
Math.exp Function Returns e (the base of natural logarithms) raised to a power.
Math.expm1 Function Returns the result of subtracting 1 from e (the base of the natural logarithms) raised to a power).
Math.floor Function Returns the greatest integer that is less than or equal to the supplied numeric expression.
Math.hypot Function Returns the square root of the sum of the squares of the arguments.
Math.imul Function Returns the product of two numbers that are treated as 32-bit signed integers.
Math.log Function Returns the natural logarithm of a number.
Math.log1p Function Returns the natural logarithm of 1 + a number.
Math.log10 Function Returns the base 10 logarithm of a number.
Math.log2 Function Returns the base 2 logarithm of a number.
Math.max Function Returns the greater of two supplied numeric expressions.
Math.min Function Returns the lesser of two supplied numbers.
Math.pow Function Returns the value of a base expression raised to a specified power.
Math.random Function Returns a pseudorandom number between 0 and 1.
Math.round Function Returns a specified numeric expression rounded to the nearest integer.
Math.sign Function Returns the sign of a number, indicating whether the number is positive, negative, or 0.
Math.sin Function Returns the sine of a number.
Math.sinh Function Returns the inverse hyperbolic sine of a number.
Math.sqrt Function Returns the square root of a number.
Math.tan Function Returns the tangent of a number.
Math.tanh Function Returns the hyperbolic tangent of a number.
Math.trunc Function Returns the integer portion of a number, removing any fractional digits.

See Also

JavaScript Objects
Number Object