Sitemap
nada yousery

nada yousery

Front-End Developer

JavaScript Math Methods

2 min readNov 26, 2020

--

Introduction:

JavaScript makes it easy for us to use Mathematics Functions for us by using JavaScript Math Object Methods.

in this article, we will cover Most of JS Math methods

there is a lot of Math methods in js so let's go ahead and start it
(note: as we know math in js is an object so if we want to call any method in this object we will access it by dot (Syntax: Math.methodName) )

Math Methods :

Math.ceil(x) : to get the value of x Rounded up to its nearest integer
Ex: Math.ceil(5.4) //6

Math.floor(x) : to get the value of x Rounded down to its nearest integer
Ex: Math.floor(5.6) //5

Math.round(x) : to get the nearest to integer
Ex: Math.floor(5.6) //6
Math.floor(5.4) //5

Math.min(x1,x2,x3,x4) : to get the Minimum value in the argument
Ex: Math.min(5,10,2,6) //2

Math.max(x1,x2,x3,x4) : to get the Maximum value in the argument
Ex: Math.min(5,10,2,6) //10

Math.random() : to return a random number
Ex: Math.random() // random number

Math.pow(x,y) : to get x power y (xy)
Ex: Math. pow(8,2) // 82 =64

Math.sqrt(x) : to get x square root
Ex: Math.sqrt(16) // √16 = 4

Math.PI : to get pi (π) value
Ex: Math.PI // 3.14

Math.abs(): to get (x) absolute value (positive value)
Ex: Math.abs(-4.52) // 4.52

Math.sin(): to get sin value of (x)
Ex: Math.sin (90) // 1

Math.cos (): to get cos value of (x)
Ex: Math.cos (90) // 0

Get nada yousery’s stories in your inbox

Join Medium for free to get updates from this writer.

Math.tan (): to get tan value of (x)
Ex: Math.tan (45) // 1

Math.trunc(x): to get the integer value of (x)
Ex: Math.trunc (5.65) // 5

sinh(x) : to get the hyperbolic sine of x

tanh(x) : to get the hyperbolic tangent of a number

cosh(x) : to get the hyperbolic cosine of x

acos(x) : to get arccosine of x

acosh(x) : to get hyperbolic arccosine of x

asin(x) : to get arcsine of x

asinh(x) : to get hyperbolic arcsine of x

atan(x) : to get arctangent of x as a numeric value between -PI/2 and PI/2 radians

atan2(x) : to get arctangent of the quotient of its arguments

atanh(x) : to get the hyperbolic arctangent of x

log(x) : to getthe natural logarithm (base E) of x (㏒e; also, ㏑)

--

--