Open In App

JavaScript Math Reference

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Share
Report issue
Report

JavaScript Math object is used to perform mathematical operations on numbers. Math is an inbuilt object that works with numbers types but it does not work with BigInt.

Example: Below example will give you a brief idea of JavaScript math objects.

javascript




// Return PI value(3.141592653589793)
console.log(Math.PI);


Output: This will print the value of Pi on the console.

3.141592653589793 

JavaScript Math object properties and methods in JavaScript are listed below:

JavaScript Math Properties: A JavaScript property is a member of an object that associates a key with a value, in the math object of JavaScript there is a single type of property that are the static properties no instance properties are there.

  • Static Property: A static property is a property that has the same value for the entire class.

Static Properties

Description

Example

E The exp is a mathematical constant having an approximate value equal to 2.718.
Try

LN2 Find the value of a natural log of 2.
Try

LN10 Find the value of a natural log of 10.
Try

LOG2E Find the value of base 2 logarithms of e, where e is approximately equal to1.442
Try

LOG10E Find the value of base 10 logarithms of e, where e is approximately equal to 0.434.
Try

PI Find the value of Pi
Try

SQRT1_2 Find the value of the square root of 1/2, whose value is approximately 0.707106.
Try

SQRT2 Find the value of the square root of 2, whose value is approximately 1.4142
Try

 

JavaScript Math Methods: JavaScript methods ar There are e actions that can be performed on objects. Only static methods are available in the math object of JavaScript.

  • Static Method: If the method is called using the Math class itself then it is called a static method of Math class.

Static Methods

Description

Example

abs() Return the absolute value of a number.
Try

acos() Return the arccosine of a number in radians.
Try

acosh() Return the hyperbolic arc-cosine of a number.
Try

asin() Return the arcsine of a number in radians
Try

asinh() Return the arctangent of a number in radians.
Try

atan() Return the arctangent of a number in radians.
Try

atan2() Return the arctangent of the quotient of its arguments.
Try

atanh() Return the hyperbolic arctangent of a number.
Try

cbrt() Find the cube root of a number.
Try

ceil() Passed as a parameter to its nearest integer in an Upward direction of Rounding.
Try

clz32() Stands for “Count Leading Zeroes 32”.
Try

cos() Return the cosine of a number.
Try

cosh() Calculate the value of the hyperbolic cosine of a number.
Try

exp() Return ex, where x is the argument, and e is Euler’s number.
Try

expm1() Get the value of ep-1, where p is any given number.
Try

floor() The number is passed as a parameter to its nearest integer in a Downward direction of rounding.
Try

fround() Find the nearest 32-bit single-precision float representation of a given Number.
Try

hypot() Calculate the square root of the sum of squares of numbers passed to it as arguments.
Try

imul() Calculate the result of the 32-bit multiplication of the two integers passed as parameters to it
Try

log() Return the natural logarithm (base e) of a number.
Try

log1p() Gives the value of the natural logarithm of 1 + p number.
Try

log2() Gives the value of base 2 logarithms of any number.
Try

log10() Gives the value of base 10 logarithms of any number.
Try

max() Return the largest of zero or more numbers.
Try

min() Return the lowest-valued number passed in the method.
Try

pow() The value of the number raised to some exponent.
Try

random() Return a floating-point pseudo-random number between range [0,1), 0 (inclusive), and 1 (exclusive).
Try

round( ) The number is passed as a parameter to its nearest integer.
Try

sign( ) Sign of a number, indicating whether the number specified is negative or positive.
Try

sin() Return the sine of a number.
Try

sinh() The root of the number is passed as a parameter to the function.
Try

sqrt( ) The root of the number is passed as a parameter to the function.
Try

tan() Return the tangent of a number.
Try

tanh() Calculate the value of the hyperbolic tangent of a number.
Try

trunc() Return the integer part of a floating-point number by removing the fractional digits.
Try



Last Updated : 26 May, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads