Javascript Math

In JavaScript, Math is a built-in object. It has both properties and methods for mathematical functions and constants.

Math operates with the Number type, but never with BigInt.

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.

w3docs logo Javascript math logarithm


The natural logarithm of 10; nearly 2.303.

w3docs logo Javascript math logarithm


E’s base 2 logarithm; nearly 1.443.

w3docs logo Javascript math logarithm


E’s base 10 logarithm; nearly 0.434.

w3docs logo Javascript math logarithm


The circumference ratio of a circle to its diameter ,nearly 3.14159.

w3docs logo Javascript math pi


½ square root ( or correspondingly 1/√2); nearly 0.707.

w3docs logo Javascript math square root


The square root of 2; nearly 1.414.

w3docs logo Javascript math square root

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.

w3docs logo Javascript math absolute value
console.log(Math.abs(-10)); console.log(Math.abs('-10')); console.log(Math.abs(-20 * 2));


Returning the arccosine (in radians) of a number.

w3docs logo Javascript math arccosine
console.log(Math.acos(0.75)); console.log(Math.acos(-0.9)); console.log(Math.acos(3));


Returning the hyperbolic arccosine of a number.

w3docs logo Javascript math arccosine
console.log(Math.acosh(1)); console.log(Math.acosh(1.5)); console.log(Math.acosh(0.99));


Returning the arcsine of a number.

w3docs logo Javascript math asine
console.log(Math.asin(0.75)); console.log(Math.asin(-0.9)); console.log(Math.asin(2));


Returning the hyperbolic arcsine of a number.

w3docs logo Javascript math asinh
console.log(Math.asinh(1)); console.log(Math.asinh(1.5)); console.log(Math.asinh(-2));


Returning the arctangent of a number.

w3docs logo Javascript math arctangens
console.log(Math.atan(0.75)); console.log(Math.atan(-0.9)); console.log(Math.atan(2));


Returning the largest integer that is less than or equal to a number.

w3docs logo Javascript math floor
console.log(Math.floor(2.65)); console.log(Math.floor(7.1)); console.log(Math.floor(5.8));

Math.pow(x, y)

Returns the exponent power base, which is xy.

w3docs logo Javascript math round
console.log(Math.pow(3, 3)); console.log(Math.pow(4, 2)); console.log(Math.pow(2, 5));


Returning a number’s value rounded to the nearest integer.

w3docs logo Javascript math round
console.log(Math.round(32.65)); console.log(Math.round(7.4)); console.log(Math.round(6.1));


Returning a number’s sine.

w3docs logo Javascript math sin
console.log(Math.sin(2)); console.log(Math.sin(0)); console.log(Math.sin(-1));


Returning the positive square root of a number.

w3docs logo Javascript math sqrt
console.log(Math.sqrt(81)); console.log(Math.sqrt(16)); console.log(Math.sqrt(-4));
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.

Do you find this helpful?