Math Constants
Math.E
Euler’s number (approximately 2.718).Math.LN2
Natural logarithm of 2 (approximately 0.693).Math.LN10
Natural logarithm of 10 (approximately 2.303).Math.LOG2E
Base-2 logarithm of E (approximately 1.443).Math.LOG10E
Base-10 logarithm of E (approximately 0.434).Math.PI
Pi (approximately 3.14159).Math.SQRT1_2
Square root of 1/2 (approximately 0.707).Math.SQRT2
Square root of 2 (approximately 1.414).Basic Operations
Math.abs
Returns absolute value.Math.sign
Returns sign of a number (-1, 0, or 1).Math.ceil
Rounds up to nearest integer.Math.floor
Rounds down to nearest integer.Math.round
Rounds to nearest integer.Math.trunc
Removes fractional part.Min/Max
Math.min
Returns smallest value.Math.max
Returns largest value.Power and Root
Math.pow
Returns base to the exponent power.Math.sqrt
Returns square root.Math.cbrt
Returns cube root.Math.hypot
Returns square root of sum of squares.Exponential and Logarithmic
Math.exp
Returns e raised to a power.Math.expm1
Returns e^x - 1.Math.log
Returns natural logarithm.Math.log10
Returns base-10 logarithm.Math.log2
Returns base-2 logarithm.Math.log1p
Returns ln(1 + x).Trigonometric
Math.sin
Returns sine.Math.cos
Returns cosine.Math.tan
Returns tangent.Math.asin
Returns arcsine.Math.acos
Returns arccosine.Math.atan
Returns arctangent.Math.atan2
Returns arctangent of quotient.Math.sinh
Returns hyperbolic sine.Math.cosh
Returns hyperbolic cosine.Math.tanh
Returns hyperbolic tangent.Math.asinh
Returns hyperbolic arcsine.Math.acosh
Returns hyperbolic arccosine.Math.atanh
Returns hyperbolic arctangent.Random
Math.random
Returns a random number between 0 (inclusive) and 1 (exclusive).Bitwise Operations
Math.clz32
Returns number of leading zero bits in 32-bit binary representation.Math.imul
Returns 32-bit integer multiplication.Math.fround
Returns nearest 32-bit float representation.Usage Examples
Circle Calculations
Distance Calculation
Clamping Values
Lerp (Linear Interpolation)
See Also
- Date Built-ins - Date calculations
- Global Functions - parseInt, parseFloat, isNaN, isFinite