Some JavaScript Math & Number Topic That Every JavaScript Developer Should Know……

Md. Touhiduzzaman
4 min readNov 9, 2020
Photo By Java Script Math Function, educba

Math.abs()

Math.abs() method return the absolute value of a number that means result of the number is always is positive.

Syntax — Math.abs(x)

Math.sqrt()

Math.sqrt() return square root of a number. If number is negative it will show NaN.

Syntax — Math.sqrt(x)

Math.round()

Math.round() method return rounded value of the nearest. In these method if number is greater than or equal 0.5 then it will count the next number like 4.56 = 5 and if number is less than 0.5 then it will ignore the decimal number like 5.49 = 5.

Syntax — Math.round(x)

Math.ceil()

Math.ceil() method return rounded number up to the next integer. If the number is null then it will show 0 not NaN. If number is 2.9999 = 3, 3.0001 = 4.

Syntax — Math.ceil(x)

Math.floor()

Math.floor() method return rounded number. It’s basically ignore the decimal number. If the number is null then it will show 0 not NaN. If number is 2.9999 = 2, 3.0001 = 3.

Syntax — Math.floor(x)

Math.random()

Math.random() mehtod return a random decimal number from 0 to 1.

Syntax — Math.random()

Math.min()

Math.min() method return the lowest number from given input number. If given input is not number or it can’t be converted to number then it will return NaN. And if no parameter set then it will show infinite.

Syntax — Math.min(value1, value2, value3….valueN)

Here value is Parameter. All parameters are number

Math.max()

Math.min() method return the highest number from given input number. If given input is not number or it can’t be converted to number then it will return NaN. And if no parameter set then it will show -infinite.

Syntax — Math.max(value1, value2, value3….valueN)

Here value is Parameter. All parameters are number

Math.pow()

Math.pow() method return base of the exponent of power.

Syntax — Math.pow(base, exponent)

Math.exp()

Math.exp() method return e^x, where x is the arguments.

Syntax — Math.exp(x)

Math Function Pi, Sin, Cos, Tan

Math.Pi method return ratio of the circumference of a circle to its diameter, approximately 3.14159

Math.sin() return the sine of a number.

Math.cos() return the cosine of a number.

Math.tan() return the tangent of a number.

Number

Number.isNaN()

Number.isNaN() method determines whatever the value is NaN and check it’s type is Number or Not.

Syntax — Number.isNaN(value)

Here value is the given test number or input number

Number.parseInt()

Number.parseInt() method return the integer number of given number.

Number.parseFloat()

Number.parseFloat() method return the floating point number of given number.

--

--