Math API

JavaScript mathematical operations and constants.

Math is a built-in object that provides mathematical constants and functions for operations such as trigonometry, logarithms, exponents, and other calculations.

Unlike most JavaScript objects, Math is not a constructor. All properties and methods of Math are static. You use mathematical constants like Math.PI and Math.E as fixed values, and mathematical functions like Math.sin(), Math.cos(), Math.tan(), Math.log(), and Math.exp() for trigonometric and exponential operations. Utility functions such as Math.min(), Math.max(), Math.abs(), Math.floor(), Math.ceil(), and Math.round() handle common numeric operations.

17 Total 9 Methods 8 Properties 17 Statics
  Show all

Math.E

Euler's number, the base of natural logarithms, approximately 2.718.Math.E

Math.LN10

Natural logarithm of 10, approximately 2.303.Math.LN10

Math.LN2

Natural logarithm of 2, approximately 0.693.Math.LN2

Math.LOG10E

Base-10 logarithm of E, approximately 0.434.Math.LOG10E

Math.LOG2E

Base-2 logarithm of E, approximately 1.442.Math.LOG2E

Math.PI

Ratio of a circle's circumference to its diameter, approximately 3.14159.Math.PI

Math.SQRT1_2

Square root of 1/2, approximately 0.707.Math.SQRT1_2

Math.SQRT2

Square root of 2, approximately 1.414.Math.SQRT2

Math.abs(…)

Returns the absolute value of a number.Math.abs(x)

Math.ceil(…)

Returns the smallest integer greater than or equal to a number.Math.ceil(x)

Math.floor(…)

Returns the largest integer less than or equal to a number.Math.floor(x)

Math.max(…)

Returns the largest of zero or more numbers.Math.max(...value1)

Math.min(…)

Returns the smallest of zero or more numbers.Math.min(...value1)

Math.pow(…)

Returns the base to the exponent power, that is, base^exponent.Math.pow(base, exponent)

Math.random()

Returns a pseudo-random number between 0 and 1.Math.random()

Math.round(…)

Returns the value of a number rounded to the nearest integer.Math.round(x)

Math.sqrt(…)

Returns the square root of a number.Math.sqrt(x)

Math.PI

staticproperty

Ratio of a circle's circumference to its diameter, approximately 3.14159. Math.PI

Beginner Examples

Pi constant.Math.PI3.141592653589793

Rounded to 2 decimal places.Math.PI.toFixed(2)3.14

You seem to be offline. App may not work.