JavaScript offers a powerful tool for performing mathematical operations through the object. It's static, meaning you don't need to create an instance of it. You can directly use its methods and properties with .
Some of the important properties include:
- // returns Euler's number
- // returns PI
- // returns the square root of 2
- // returns the square root of 1/2
- // returns the natural logarithm of 2
- // returns the natural logarithm of 10
- // returns base 2 logarithm of E
- // returns base 10 logarithm of E
Here are some examples of math methods:
- // 9
- // 5
- // 6
- // 5
- // 5
- // -1
- // 5
- // 7.2
- // 1 (the sine of 90 degrees)
- // 1 (the cosine of 0 degrees)
- // -200
- // 150
- // A random number between 0 and 1
- // 1
- // 3
- // 3
These methods are accessed directly, and you provide the necessary arguments. For example, returns 8, as it calculates 2 raised to the power of 3.
Here's a quick reference for some common methods:
| Method | Description |
|---|---|
| Returns absolute value of x | |
| Returns arccosine of x, in radians | |
| Returns hyperbolic arccosine of x | |
| Returns arcsine of x, in radians | |
| Returns hyperbolic arcsine of x | |
| Returns arctangent of x as a numeric value between -PI/2 and PI/2 radians | |
| Returns arctangent of the quotient of its arguments | |
| Returns hyperbolic arctangent of x | |
| Returns cubic root of x | |
| Returns rounded upwards to the nearest integer of x | |
| Returns cosine of x, in radians | |
| Returns hyperbolic cosine of x | |
| Returns exponential value of x | |
| Returns round downwards to the nearest integer of x | |
| Returns natural logarithmetic of x | |
| Returns number with the highest value | |
| Returns number with the lowest value | |
| Returns value of x to the power of y | |
| Returns number between 0 and 1 | |
| Rounds number to the nearest x | |
| Returns if x is negative, null or positive (-1,0,1) | |
| Returns sine of x, in radians | |
| Returns hyperbolic sine of x | |
| Returns square root of x | |
| Returns tangent of an angle | |
| Returns hyperbolic tangent of x | |
| Returns integer part of a number (x) |
These methods are accessed directly, and you provide the necessary arguments. For example, returns 8, as it calculates 2 raised to the power of 3.