Math
The Math object contains lots of math-related utilities.
It provides us a lot of properties and functions that we can use to perform calculations.
Properties
Math.E
e, base of the natural logarithm (means ~2.71828)Math.LN10
represents the base e (natural) logarithm of 10Math.LN2
represents the base e (natural) logarithm of 2Math.LOG10E
represents the base 10 logarithm of eMath.LOG2E
represents the base 2 logarithm of eMath.PI
the Ο constant (~3.14159)Math.SQRT1_2
represents the reciprocal of the square root of 2Math.SQRT2
represents the square root of 2
Methods
All those methods are static.
Math.abs()
Returns the absolute value of a number
Math.acos()
Returns the arccosine of the operand
The operand must be between -1 and 1
Math.asin()
Returns the arcsine of the operand
The operand must be between -1 and 1
Math.atan()
Returns the arctangent of the operand
Math.atan2()
Returns the arctangent of the quotient of its arguments.
Math.ceil()
Rounds a number up
Math.cos()
Return the cosine of an angle expressed in radiants
Math.exp()
Return the value of Math.E multiplied per the exponent thatβs passed as argument
Math.floor()
Rounds a number down
Math.log()
Return the base e (natural) logarithm of a number
Math.max()
Return the highest number in the set of numbers passed
Math.min()
Return the smallest number in the set of numbers passed
Math.pow()
Return the first argument raised to the second argument
Math.random()
Returns a pseudorandom number between 0.0 and 1.0
Math.round()
Rounds a number to the nearest integer
Math.sin()
Calculates the sin of an angle expressed in radiants
Math.sqrt()
Return the square root of the argument
Math.tan()
Calculates the tangent of an angle expressed in radiants
Last updated
Was this helpful?