Unlike other global objects, Math is not considered a constructor. The methods and properties of Math are fixed. You can call them by applying Math as an object without creating it.
So, you refer to constant pi as Math.PI. Hence, the sine function should be called Math.sin(x). Here, x is the argument of the method.
The syntax to call the methods and properties of Math is the following:
var pi_value = Math.PI; var sin_value = Math.sin(30);
Properties of Math
Now let’s check out the list of math properties with their descriptions.
The natural logarithm of 2: nearly 0.693.
The natural logarithm of 10; nearly 2.303.
E’s base 2 logarithm; nearly 1.443.
E’s base 10 logarithm; nearly 0.434.
The circumference ratio of a circle to its diameter ,nearly 3.14159.
½ square root ( or correspondingly 1/√2); nearly 0.707.
The square root of 2; nearly 1.414.
The Methods of Math
Below you will find the list of the math methods and their descriptions;
This method is targeted at returning the absolute value of a number.
Returning the arccosine (in radians) of a number.
Returning the hyperbolic arccosine of a number.
Returning the arcsine of a number.
Returning the hyperbolic arcsine of a number.
Returning the arctangent of a number.
Returning the largest integer that is less than or equal to a number.
Returns the exponent power base, which is xy.
Returning a number’s value rounded to the nearest integer.
Returning a number’s sine.
Returning the positive square root of a number.
|Math.E||Euler’s constant as well as natural logarithms’ base; nearly 2.718.|
|Math.atanh(x)||Returning the hyperbolic arctangent of a number.|
|Math.atan2(y, x)||Returning the arctangent of its arguments’ quotient.|
|Math.cbrt(x)||Returning a number’s cube root.|
|Math.ceil(x)||Returning the smallest integer that is greater than or equal to a number.|
|Math.clz32(x)||Returning the number of leading a 32-bit integer zeros.|
|Math.cos(x)||Returning the cosine of a number.|
|Math.cosh(x)||Returning a number’s hyperbolic cosine.|
|Math.exp(x)||Returning Ex, where x is the argument, and E is Euler's constant (2.718…, the natural logarithm base).|
|Math.expm1(x)||Returning subtracting 1 from exp(x).|
|Math.fround(x)||Returning a number’s nearest single-precision float representation.|
|Math.hypot([x[, y[, …]]])||Returning the square root of the sum of squares of its arguments.|
|Math.imul(x, y)||Returning a 32-bit integer multiplication result.|
|Math.log(x)||Returning a number’s natural logarithm (㏒e; also, ㏑).|
|Math. (x)||Returning the natural logarithm (㏒e; also ㏑) of 1 + x for a number.|
|Math.log10(x)||Returning a number’s base 10 logarithm.|
|Math.log2(x)||Returning a number’s base 2 logarithm.|
|Math.max([x[, y[, …]]])||Returning the largest of zero or more numbers.|
|Math.min([x[, y[, …]]])||Returning the smallest of zero or more numbers.|
|Math.random()||Returning a pseudo-random number between 0 and 1.|
|Math.sign(x)||Returning the x sign, indicating whether x is positive, negative, or zero.|
|Math.sinh(x)||Returning a number’s hyperbolic sine.|
|Math.tan(x)||Returning a number’s tangent.|
|Math.tanh(x)||Returning the hyperbolic tangent of a number.|
|Math.toSource()||Returning the string "Math".|
|Math.trunc(x)||Returning the integer part of the number x and removing each fractional digit.|