JavaScript Math Object

From Techotopia
Revision as of 20:39, 17 May 2007 by Neil (Talk | contribs)

Jump to: navigation, search

The JavaScript Math object provides a collections of mathematical constants and methods for performing such tasks as generating random numbers, rounding, obtaining values such as PI and performing calculations.

The following table lists the methods available with the Math object:

Method Description
abs Absolute value
sin, cos, tan Standard trigonometric functions; argument in radians
acos, asin, atan, atan2 Inverse trigonometric functions; return values in radians
exp, log Exponential and natural logarithm, base e
ceil Returns least integer greater than or equal to argument
floor Returns greatest integer less than or equal to argument
min, max Returns greater or lesser (respectively) of two arguments
pow Exponential; first argument is base, second is exponent
random Returns a random number between 0 and 1.
round Rounds argument to nearest integer
sqrt Square root