The JavaScript Math Objects provides various Functions and Constants / Properties, which allows us to perform mathematical functions.
Unlike other global objects, Properties and Functions are available inside the math object is static. So, we can access the properties as Math.PI and JavaScript math functions as Math.abs(number).
JavaScript Math Object Properties
The following table will show you the list of Properties or Constants available in JavaScript Math Object
JavaScript Math Properties | Description |
---|---|
Math.E | It will return the Euler’s Number e, approximately equal to 2.71828 |
Math.LN2 | It will return Natural Logarithm of 2, approximately equal to 0.693 |
Math.LN10 | This JavaScript Math Function returns the Natural Logarithm of 10, approximately equal to 2.302 |
Math.LOG2E | It will return Logarithm of E base 2, approximately equal to 1.443 |
Math.LOG10E | It will return Logarithm of E base 10, approximately equal to 0.434 |
Math.PI | This JavaScript Math Function returns the Pie Value, approximately equal to 3.14 |
Math.SQRT1_2 | It returns Square Root of 1/2 or 0.5, approximately equal to 0.707 |
Math.SQRT2 | It will return Square Root of 2, approximately equal to 1.414 |
JavaScript Math Object Methods
The following table will show you the list of Functions available in JavaScript Math Object. To use the below functions, we have to use the Math object as a prefix. For example, Math.abs(x)
JavaScript Math Functions | Description |
---|---|
abs(x) | It returns the Absolute value of a Given number |
acos(x) | It will return the ArcCosine value of a Given number |
acosh(x) | Used to return the Hyperbolic Arc Cosine (inverse Hyperbolic Cosine) value of a supplied number |
asin(x) | This JavaScript Math Function will return the Arc Sine value of a number |
asinh(x) | It will return the Hyperbolic Arc Sine (inverse Hyperbolic Sine) value of a supplied number |
atan(x) | This returns the Arc Tangent value of a Given number |
atan2(y, x) | It will return the angle (in radius) from the X-Axis to the specified point (y, x). |
cbrt(x) | Used to find the Cube Root of a supplied number |
atanh(x) | Returns the Hyperbolic Arc Tangent (inverse Hyperbolic Tangent) value of a number |
ceil(x) | It is used to return the smallest integer value which is greater than or equal to the specified expression or a number. |
cos(x) | This returns the Cosine value of a Given number |
cosh(x) | Return the Hyperbolic Cosine value of a supplied number |
exp(x) | It is used to calculate the power of E, Where E is Euler’s number approximately equal to 2.71828. |
floor(x) | This JavaScript Math Function returns the largest integer value which is less than or equal to the specified expression or a number. |
hypot(value1, value2,…..valueN) | It will extract the characters from a string based on the specified indices |
log(x) | It calculates the logarithmic value of specified number with base E. |
max(1, 2, 3, …..n) | It is used to return the Maximum or Largest value from the specified set of expression |
min(1, 2, 3, …..n) | This JavaScript Math Function return the Minimum or Smaller value from the specified set of expression |
pow(x, y) | It is used to calculate the Power of the specified expression |
random() | This function will return the random number between 0 and 1 |
round(x) | It is used to round the specified expression or an individual number to the nearest integer. |
sign(x) | This JavaScript Math Function returns the sign of a Given number. For instance, Positive, Negative or Zero |
sin(x) | Return the Sine value of a number |
sinh(x) | Return the Hyperbolic Sine value of a specified number |
sqrt(x) | It is used to find the square root of a specified expression or an individual number |
tan(x) | Return the Tangent value of a specified number |
tanh(x) | This JavaScript Math Function returns the Hyperbolic Tangent value of a number |
trunc(x) | It is used to remove the decimal values from specified expression and return the integer value |