JavaScript Reference :: Math

The Math object is a static class. As such, all methods and properties are referenced from the Math class, not an instance of the Math class.

methods

float abs(float)
Returns the absolute value of the value provided.
float acos(float)
Returns the arcosine of the value provided.
float asin(float)
Returns the arcsine of the value provided.
float atan(float)
Returns the arctangent of the value provided.
float atan2(float)
int ceil(float)
Rounds the value provided up to the next integer.
float cos(float)
Returns the cosine of the value provided.
float eval(string)
Evaluates the string provided and returns the result. If the string does not evaluate to a number, a non-numeric (NaN) is returned.
float exp(float)
Returns the value of Ex, where E is Euler's constant and x is the value provided.
int floor(float)
Rounds the value provided down to the next integer.
float log(float)
Returns the natural logarithm of the value provided.
float max(float, float)
Returns the greater of the values provided.
float min(float, float)
Returns the lesser of the values provided.
float pow(float base, float exponent)
Returns the value of the base raised to power of the exponent.
float random()
Returns a positive value less than one.
int round(float)
Rounds the value provided according to the standard rule.
float sin(float)
Returns the sine of the value provided.
float sqrt(float)
Returns the square root of the value provided.
float tan(float)
Returns the tangent of the value provided.
object toSource()
Returns a literal representing the source code of the object e.g "function Object() { [native code] }" or "function Car(manufactuer, model, productionyear) { this.make = manufactuer; this.model = model; this.year = productionyear; }".
string toString()
Returns a string representing the object i.e. "[object Object]".
void unwatch(property)
Removes a previously set watchpoint.
								
object valueOf()
Returns the primitive value of the object e.g. "function Object() { [native code] }".
void watch(property, handlingFunction)
Calls the handlingFunction when the property is changed.
								

properties

constructor
The constructor method is the base method used to create an instance of the object.
E
The base of natural logrithms, approximately 2.7183.
LN10
The natural logrithm of 10, aproximately 2.3026.
LN2
The natural logrithm of 2, approximately 0.6931.
LOG10E
The base 10 logarithm of E, approximately 0.4343.
LOG2E
The base 2 logarithm of E, approximately 1.4427.
PI
prototype
Exposes the prototype for the method or property of the object.
SQRT1_2
The value of 1 divided by the square root of 2, approximately 0.7071.
SQRT2
The value of the square root of 2, approximately 1.4142.

events