# Math

The Math object in JavaScript

TAGS: JavaScript, Math, Programming, TECH

The Math object in JavaScript. All Math properties and methods are static that are accessed directly from the prototype as opposed to an instance.

## Properties

All the Math properties are in ALL CAPs because they are all constants.

.E. Euler's constant and the base of natural logarithms, approximately 2.718.

.LN10. Natural logarithm of 10, approximately 2.302.

.LN2. Natural logarithm of 2, approximately 0.693.

.LOG10E. Base 10 logarithm of E (approximately 0.434).

.LOG2E. Base 2 logarithm of E (approximately 1.442).

.PI. Ratio of the circumference of a circle to its diameter, approximately 3.14159.

.SQRT1_2. Square root of 1/2; equivalently, 1 over the square root of 2, approximately 0.707.

.SQRT2. Square root of 2, approximately 1.414.

## Methods

.abs(n). Returns the absolute value of a number.

.acos(n). Returns the arccosine (in radians) of a number. The acos method returns a numeric value between 0 and pi radians. If the value of number is outside this range, it returns NaN.

.asin(n). Returns the arcsine (in radians) of a number. The asin method returns a numeric value between -pi/2 and pi/2 radians. If the value of number is outside this range, it returns NaN.

.atan(n). Returns the arctangent (in radians) of a number. The atan method returns a numeric value between -pi/2 and pi/2 radians.

.atan2(y,x). Returns the arctangent of the quotient of its arguments. The atan2 method returns a numeric value between -pi and pi representing the angle theta of an (x,y) point.

.ceil(n). Returns the smallest integer greater than or equal to a number.

.cos(n). Returns the cosine of a number. The cos method returns a numeric value between -1 and 1.

.exp(n). Returns En, where n is the argument, and E is Euler's constant, the base of the natural logarithms.

.floor(n). Returns the largest integer less than or equal to a number.

.log(n). Returns the natural logarithm (base E) of a number.

.max(m,n). Returns the greater of two numbers.

.min(m,n). Returns the lesser of two numbers.

.pow(base,exponent). Returns base to the exponent power, that is, baseexponent.

.random(). Returns a pseudo-random number between 0 and 1. (Seeded from the current time)

.round(n). Returns the value of a number rounded to the nearest integer.

.sin(n). Returns the sine of a number. 1, which represents the sine of the argument.

.sqrt(n). Returns the square root of a number.

.tan(n). Returns the tangent of a number.

GeorgeHernandez.comSome rights reserved