In Javascript, mathematical methods can be divided into the following types:
Constans (constant), power functions (multiplication function), trigonometic functions (trigonometric function), rounding functions (rounding function), random numbers (random number)
Constants and multiplication Functions
Math. E |
Base of natural logarithm (constant) |
2.718 |
Math. LN10 |
Natural logarithm of 10 |
2.302 |
Math. LN2 |
Natural logarithm of 2 |
0.693 |
Math. PI |
Circumference Rate |
3.1415 |
Math. SQRT1_2 |
Square root of 1/2 |
0.707 |
Math. SQRT2 |
Square root of 2 |
1.414 |
Math. sqrt (x) |
Square root of X |
It depends on the value of X. |
Math. pow (x, n) |
Returns the nth power of x. |
The parameters are x and n. |
Math. log (n) |
Returns the natural logarithm of n. |
The parameter is n. |
Math. exp (n) |
Returns the nth power of e. |
The parameter is n. |
Trigonometric function
Math. cos (x) |
Returns the cosine of X. |
Math. sin (x) |
Sine function of X |
Math. tan (x) |
Returns the tangent of X. |
Math. acos (y) |
Returns the arc cosine of X. |
Math. asin (y) |
Returns the arcsin of X. |
Math. atan (y) |
Returns the arc tangent function of X. |
Note: The unit of the return values of parameter x and inverse functions is radian (for example, PI radian = 180 degrees)
Rounding functions and random numbers
Math. random () |
Generate a random number from 0 to 1 |
Math. round (x) |
Returns the value closest to integer x. |
Math. floor (x) |
Returns the value closest to integer x and smaller than x. |
Math. ceil (x) |
Returns the value closest to integer x and greater than x. |
Math. min (a, B, c) |
Returns the smallest value in the parameter list. |
Math. max (a, B, c) |
Returns the maximum value in the parameter list. |