Changes

Jump to: navigation, search

JavaScript Math Object

1,295 bytes added, 20:39, 17 May 2007
New page: 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 pe...
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:

<table class="fullwidth-table">
<tr>
<th>Method</th>
<th>Description</th>
</tr>
<tr>
<td>abs</td>
<td>Absolute value </td>
</tr>
<tr>
<td>sin, cos, tan</td>

<td>Standard trigonometric functions; argument in radians </td>
</tr>
<tr>
<td>acos, asin, atan, atan2</td>
<td>Inverse trigonometric functions; return values in radians </td>
</tr>
<tr>
<td>exp, log</td>
<td>Exponential and natural logarithm, base <sub>e</sub></td>
</tr>
<tr>

<td>ceil</td>
<td>Returns least integer greater than or equal to argument </td>
</tr>
<tr>
<td>floor</td>
<td>Returns greatest integer less than or equal to argument </td>
</tr>
<tr>
<td>min, max</td>
<td>Returns greater or lesser (respectively) of two arguments </td>
</tr>

<tr>
<td>pow</td>
<td>Exponential; first argument is base, second is exponent </td>
</tr>
<tr>
<td>random</td>
<td>Returns a random number between 0 and 1. </td>
</tr>
<tr>
<td>round</td>
<td>Rounds argument to nearest integer </td>

</tr>
<tr>
<td>sqrt</td>
<td>Square root</td>
</table>

Navigation menu