Tutorials » Javascript tutorials »

# The Math Object

The JavaScript math object can be called without creating a new object for it.
The JavaScript Math object is used to compute common mathematical calculations. It includes several mathematical functions that can help in mathematical calculations.

# Methods

Here are some important methods about Javascript Math Object

### abs

abs(a) Returns absolute value of a.
ex: Math.abs(-2) results as 2

### acos

acos(a) returns cosine of a in radians
ex: Math.acos(0) results as 1

### asin

asin(a) returns cosine of a in radians
ex: Math.asin(0) results as 0

### atan

acos(a) returns tan of a in radians
ex: Math.tan(0) results as 0

### atan2

atan2(b,a)returns counterclockwise angle between x axis and point (b,a).

### ceil

ceil(a) - rounds up the value of "a" to the next integer.
ex: ceil(3.14) results as 3

### exp

exp(a) returns e to the power of a

### floor

floor(x) rounds the passed value down to the next lowest integer.
ex: floor(3.74) results as 3

### log

log(x) returns the natural logarithm (base E) of x

### max

max(a,b) returns the larger value of a or b.
ex: Math.max(5,7) results as 7

### min

min(a,b) returns the smaller value of a or b.
ex: Math.min(5,7) results as 5

### pow

pow(a,b) returns the value of a to the power b
ex: Math.pow(5,2) results as 25

### random

random(a,b) returns a random number between 0 and 1

### round

round(a) returns the value of a to the nearest integer.
ex: Math.round(5.2) results as 5

### sqrt

sqrt(a) returns the value of square root of a
ex: Math.sqrt(25) results as 5

Next Chapter: Math Object - Example
Previous Chapter: Array Object methods
More Chapters: Javascript Tutorials
More Tutorials: Tutorial Index

Top Contributors
TodayLast 7 Daysmore...