Platform Support
IE | Mozilla | Netscape | Opera | Safari | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+ |
---|
Properties
Property | Action | IE | Mozilla | Netscape | Opera | Safari |
---|---|---|---|---|---|---|
static E
: Number
Euler's constant and the base of natural logarithms,
approximately 2.718.
|
Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+ |
|
||||||
static LN10
: Number
The natural logarithm of 10, approximately 2.302.
|
Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+ |
|
||||||
static LN2
: Number
The natural logarithm of 2, approximately 0.693.
|
Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+ |
|
||||||
static LOG10E
: Number
The base 10 logarithm of E (approximately 0.434).
|
Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+ |
|
||||||
static LOG2E
: Number
The base 2 logarithm of E (approximately 1.442).
|
Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+ |
|
||||||
static PI
: Number
The ratio of the circumference of a circle to its
diameter, approximately 3.14159.
|
Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+ |
|
||||||
static SQRT1_2
: Number
The square root of 1/2; equivalently, 1 over the
square root of 2, approximately 0.707.
|
Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+ |
|
||||||
static SQRT2
: Number
The square root of 2, approximately 1.414.
|
Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+ |
|
Functions
Method | Action | IE | Mozilla | Netscape | Opera | Safari | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
static abs(Number x) : Number
Returns the absolute value of a number.
|
Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+ | ||||||||
Parameters
Returns
|
||||||||||||||
static acos(Number x) : Number
Returns the arccosine (in radians) of a number.
|
Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+ | ||||||||
Parameters
Returns
|
||||||||||||||
static asin(Number x) : Number
Returns the arcsine (in radians) of a number.
|
Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+ | ||||||||
Parameters
Returns
|
||||||||||||||
static atan(Number x) : Number
Returns the arctangent (in radians) of a number.
|
Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+ | ||||||||
Parameters
Returns
|
||||||||||||||
static atan2(Object y, Object x) : Number
Returns the arctangent of the quotient of its
arguments.
|
Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+ | ||||||||
Parameters
Returns
|
||||||||||||||
static ceil(Number x) : Number
Returns the smallest integer greater than or equal to
a number.
|
Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+ | ||||||||
Parameters
Returns
|
||||||||||||||
static cos(Number x) : Number
Returns the cosine of a number.
|
Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+ | ||||||||
Parameters
Returns
|
||||||||||||||
static exp(Number x) : Number
Returns Ex, where
x is the argument, and E is
Euler's constant, the base of the natural logarithms.
|
Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+ | ||||||||
Parameters
Returns
|
||||||||||||||
static floor(Number x) : Number
Returns the largest integer less than or equal to a
number.
|
Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+ | ||||||||
Parameters
Returns
|
||||||||||||||
static log(Number x) : Number
Returns the natural logarithm (base E) of
a number.
|
Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+ | ||||||||
Parameters
Returns
|
||||||||||||||
static max(Number x, Number y) : Number
Returns the larger of two numbers.
|
Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+ | ||||||||
Parameters
Returns
|
||||||||||||||
static min() : Number
Returns the smaller of two numbers.
|
Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+ | ||||||||
Returns
|
||||||||||||||
static pow() : Number
Returns base to the exponent power, that is, baseexponent.
|
Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+ | ||||||||
Returns
|
||||||||||||||
static random() : Number
Returns a pseudo-random number in the range [0,1)
-- that is, between 0 (inclusive) and 1 (exclusive).
The random number generator is seeded from the current
time, as in Java.
|
Show Details | 3.0+ | 1.0+ | 3.0+ | 7.0+ | 1.0+ | ||||||||
Returns
|
||||||||||||||
static round(Number x) : Number
Returns the value of a number rounded to the nearest
integer.
|
Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+ | ||||||||
Parameters
Returns
|
||||||||||||||
static sin(Number x) : Number
Returns the sine of a number.
|
Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+ | ||||||||
Parameters
Returns
|
||||||||||||||
static sqrt(Number x) : Number
Returns the square root of a number.
|
Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+ | ||||||||
Parameters
Returns
|
||||||||||||||
static tan(Number x) : Number
Returns the tangent of a number.
|
Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+ | ||||||||
Parameters
Returns
|
Remarks
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.
It is often convenient to use the with
statement when a section of code uses several
Math
constants and methods, so you don't
have to type "Math" repeatedly. For example,
with (Math) { a = PI * r*r y = r*sin(theta) x = r*cos(theta) }
References
Availability
JavaScript 1.0|JScript 1.0|ECMAScript v1