The most common uses of JavaScript Number and Math Methods
The number type is the primitive data type. It is defined by JavaScript. A number is a primitive object used to represent and manipulate numbers like 20 or -17.
NaN property- The NaN property means Not a Number. This property indicates which value is not a pure number.
isNaN() -Use the isNaN() function to check which value is NaN or Not .If the value is NaN it returns true otherwise false.
Number()- The Number() function used to convert any value to a number but if the value can not be converted to a pure number, its return NaN.
parseFloat()- This function parses a string and returns a floating number.
If the value can not be converted to a floating point, its return NaN. Some examples are given below.
parseInt()-This function parses a string and returns an integer.
If the value can not be converted to an integer, its return NaN. Some examples are given below.
Math- Math is a built-in javascript Object. It has some properties and methods for mathematical operation. Some properties and methods are given below.
Get Mosharofhossen’s stories in your inbox
Join Medium for free to get updates from this writer.
Math.abs()- This function returns the absolute value of a number.Like, it returns a number of n if n is positive or zero or negative otherwise it returns NaN. Only it returns 0 if you pass empty string/array/null.
Math.ceil()- Converting a decimal number to a whole integer number always returns the largest around value.
Math.floor()-Converting a decimal number to a whole integer number always returns the smallest around value.
Math.min()- This function returns the lowest value from a set of numbers.
Math.max()- This function returns the highest value from a set of numbers.
Math.random()- The random method returns a random number between 0(inclusive) and 1 (exclusive).
Math.round()-Converting a decimal number to a whole integer number always returns a rounded value.
Math.sqrt()- The Math.sqrt() function returns the square root of a number.
Math.pow()- This function has two-parameter . It calculates the value by the way of x^y.
Thanks everyone for continuing. Please follow my publication.







