JavaScript Math Methods

About This Index
This page is the JavaScript Math Methods index for the tutorial track. Each row links to a full guide with syntax, simple examples, and FAQs.
The Math object is built into JavaScript — no import needed. Jump to abs(), round(), sqrt(), or random() when you need a specific API.
Start with abs(), floor(), ceil(), round(), max(), min(), and random() — then open trig and constants like Math.PI.
How to Call a Math Method
All Math APIs are static. Call them on Math, not on a number instance:
// Methods (need parentheses)
Math.abs(-7); // 7
Math.round(4.6); // 5
Math.floor(4.9); // 4
Math.sqrt(25); // 5
Math.max(3, 9, 1); // 9
Math.random(); // 0 <= n < 1
// Constants (no parentheses)
Math.PI; // 3.14159...
Math.E; // 2.71828... JavaScript Math Methods Table
All Math guides in this JavaScript tutorial series (45 tutorials).
Everyday Math
12 itemsAbsolute value, rounding, min/max, powers, roots, and random numbers — start here.
| Name | Description | Tutorial |
|---|---|---|
abs() | Return the absolute value of a number — negatives become positive. | Open |
ceil() | Round a number up to the next whole number. | Open |
floor() | Round a number down to the previous whole number. | Open |
round() | Round a number to the nearest whole number. | Open |
trunc() | Remove the fractional part of a number (toward zero). | Open |
sign() | Return −1, 0, or 1 depending on the sign of a number. | Open |
max() | Return the largest of zero or more numbers. | Open |
min() | Return the smallest of zero or more numbers. | Open |
pow() | Raise a base to a power (base^exponent). | Open |
sqrt() | Return the square root of a non-negative number. | Open |
cbrt() | Return the cube root of a number. | Open |
random() | Return a random number greater than or equal to 0 and less than 1. | Open |
Trigonometry
7 itemsSine, cosine, tangent, and inverse functions. Angles use radians (not degrees).
| Name | Description | Tutorial |
|---|---|---|
sin() | Return the sine of an angle given in radians. | Open |
cos() | Return the cosine of an angle given in radians. | Open |
tan() | Return the tangent of an angle given in radians. | Open |
asin() | Return the arcsine of a number in radians (input between −1 and 1). | Open |
acos() | Return the arccosine of a number in radians (input between −1 and 1). | Open |
atan() | Return the arctangent of a number in radians. | Open |
atan2() | Return the angle of a point (y, x) from the positive x-axis, in radians. | Open |
Hyperbolic Functions
6 itemsHyperbolic sine, cosine, tangent, and their inverses.
| Name | Description | Tutorial |
|---|---|---|
sinh() | Return the hyperbolic sine of a number. | Open |
cosh() | Return the hyperbolic cosine of a number. | Open |
tanh() | Return the hyperbolic tangent of a number. | Open |
asinh() | Return the hyperbolic arcsine of a number. | Open |
acosh() | Return the hyperbolic arccosine of a number (≥ 1). | Open |
atanh() | Return the hyperbolic arctangent of a number (between −1 and 1). | Open |
Exponentials and Logarithms
6 itemseˣ, natural and base-2/10 logs, plus accurate near-zero helpers.
| Name | Description | Tutorial |
|---|---|---|
exp() | Return e raised to the power of a number (eˣ). | Open |
expm1() | Return eˣ − 1 accurately for values near zero. | Open |
log() | Return the natural logarithm (base e) of a number. | Open |
log10() | Return the base-10 logarithm of a number. | Open |
log2() | Return the base-2 logarithm of a number. | Open |
log1p() | Return ln(1 + x) accurately for values near zero. | Open |
Numeric Helpers
6 itemsDistances, integer multiply, float rounding, and bit counting.
| Name | Description | Tutorial |
|---|---|---|
hypot() | Return the square root of the sum of squares — useful for distances. | Open |
imul() | Multiply two numbers as 32-bit integers (C-like). | Open |
fround() | Round a number to the nearest 32-bit float (float32). | Open |
f16round() | Round a number to the nearest 16-bit float (float16). | Open |
clz32() | Count leading zero bits in a 32-bit integer representation. | Open |
sumPrecise() | Sum numbers with higher floating-point precision (newer API). | Open |
Math Constants
8 itemsBuilt-in constants on the Math object — no parentheses, just read the value.
| Name | Description | Tutorial |
|---|---|---|
E | Euler’s number constant ≈ 2.71828. | Open |
LN10 | Natural logarithm of 10 ≈ 2.302585. | Open |
LN2 | Natural logarithm of 2 ≈ 0.693147. | Open |
LOG10E | Base-10 logarithm of e ≈ 0.434294. | Open |
LOG2E | Base-2 logarithm of e ≈ 1.442695. | Open |
PI | Pi constant ≈ 3.14159 — circle circumference / diameter. | Open |
SQRT1_2 | Square root of ½ ≈ 0.707106. | Open |
SQRT2 | Square root of 2 ≈ 1.41421. | Open |
Frequently Asked Questions
Start with abs()
Open the absolute-value guide—syntax, examples, and FAQs.
12 people found this page helpful
