Name
Math — a placeholder for mathematical functions and constants
Availability
Core JavaScript 1.0; ECMA-262
Synopsis
Math.constantMath.function()
Constants
- Math.E
The mathematical constant e.
- Math.LN10
The mathematical constant log e 10.
- Math.LN2
The mathematical constant log e 2.
- Math.LOG10E
The mathematical constant log 10 e.
- Math.LOG2E
The mathematical constant log 2 e.
- Math.PI
The mathematical constant π.
- Math.SQRT1_2
The mathematical constant 1/2.
- Math.SQRT2
The mathematical constant 2.
Static Functions
- Math.abs(x)
Compute an absolute value.
- Math.acos(x)
Compute an arc cosine.
- Math.asin(x)
Compute an arc sine.
- Math.atan(x)
Compute an arc tangent.
- Math.atan2(x, y)
Compute the angle from the X axis to a point.
- Math.ceil(x)
Round up a number.
- Math.cos(x)
Compute a cosine.
- Math.exp(x)
Compute e x .
- Math.floor(x)
Round down a number.
- Math.log(x)
Compute a natural logarithm.
- Math.max(a, b)
Return the larger of two values.
- Math.min(a, b)
Return the smaller of two values.
- Math.pow(x, y)
Compute x y .
- Math.random()
Return a pseudo-random number. JavaScript 1.1; ECMA-262.
- Math.round(x)
Round to the nearest integer.
- Math.sin(x)
Compute a sine.
- Math.sqrt(x)
Compute a square root.
- Math.tan(x)
Compute a tangent.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access