Name
Math — a placeholder for mathematical functions and constants
Availability
Core JavaScript 1.0; ECMA-262
Synopsis
Math.constant
Math.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.
Get Webmaster in a Nutshell, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.