Math
Overview
Math provides static properties and methods for mathematical constants and functions.
For more information see: Math (MDN).
Properties Summarized
Methods Summarized
Returns Enumber, where number is the argument, and E is Euler's constant, the base of the natural logarithms.
Properties Detailed
E
Euler's constant and the base of natural logarithms. Approximately 2.718.
Type Number
Sample
Math.E
LN10
Natural logarithm of 10. Approximately 2.302.
Type Number
Sample
Math.LN10
LN2
Natural logarithm of 2. Approximately 0.693.
Type Number
Sample
Math.LN2
LOG10E
Base 10 logarithm of E. Approximately 0.434.
Type Number
Sample
Math.LOG10E
LOG2E
Base 2 logarithm of E. Approximately 1.442.
Type Number
Sample
Math.LOG2E
PI
Ratio of the circumference of a circle to its diameter. Approximately 3.14159.
Type Number
Sample
Math.PI
SQRT1_2
Square root of 1/2. Equivalently, 1 over the square root of 2, approximately 0.707.
Type Number
Sample
Math.SQRT1_2
SQRT2
Square root of 2. Approximately 1.414.
Type Number
Sample
Math.SQRT2
Methods Detailed
abs(x)
Returns the absolute value of a number.
Parameters
Number x ;
Returns: Number
Sample
Math.abs(number)
acos(x)
Returns the arccosine (in radians) of a number.
Parameters
Number x ;
Returns: Number
Sample
Math.acos(number)
asin(x)
Returns the arcsine (in radians) of a number.
Parameters
Number x ;
Returns: Number
Sample
Math.asin(number)
atan(x)
Returns the arctangent (in radians) of a number.
Parameters
Number x ;
Returns: Number
Sample
Math.atan(number)
atan2(y, x)
Returns the arctangent of the quotient of its arguments.
Parameters
Returns: Number
Sample
Math.atan2(number,number)
ceil(x)
Returns the smallest integer greater than or equal to a number.
Parameters
Number x ;
Returns: Number
Sample
Math.ceil(number)
cos(x)
Returns the cosine of a number.
Parameters
Number x ;
Returns: Number
Sample
Math.cos(number)
exp(x)
Returns Enumber, where number is the argument, and E is Euler's constant, the base of the natural logarithms.
Parameters
Number x ;
Returns: Number
Sample
Math.exp(number)
floor(x)
Returns the largest integer less than or equal to a number.
Parameters
Number x ;
Returns: Number
Sample
Math.floor(number)
log(x)
Returns the natural logarithm (base E) of a number.
Parameters
Number x ;
Returns: Number
Sample
Math.log(number)
max(value)
Returns the greater of two (or more) numbers.
Parameters
Array value ;
Returns: Number
Sample
Math.max(number,number,number)
min(value)
Returns the lesser of two (or more) numbers.
Parameters
Array value ;
Returns: Number
Sample
Math.min(number,number,number)
pow(base, exponent)
Returns base to the exponent power, that is, base exponent.
Parameters
Returns: Number
Sample
Math.pow(number,number)
random()
Returns a pseudo-random number between 0 and 1.
Returns: void
Sample
Math.random()
round(x)
Returns the value of a number rounded to the nearest integer.
Parameters
Number x ;
Returns: void
Sample
Math.round(number)
sin(x)
Returns the sine of a number.
Parameters
Number x ;
Returns: void
Sample
Math.sin(number)
sqrt(x)
Returns the square root of a number.
Parameters
Number x ;
Returns: void
Sample
Math.sqrt(number)
tan(x)
Returns the tangent of a number.
Parameters
Number x ;
Returns: void
Sample
Math.tan(number)
Last updated
Was this helpful?