There are many JavaScript Number methods that are often used to manipulate number values. These number formats support integers, floating-point numbers, such as decimal, hexadecimal, notations.
Here are a few methods that can make manipulating and modifying numeric values much easier.
-
Number() - method converts a string into a number.
-
ParseInt() - very similar to the number() method, parseInt() formats a string into an integer.
-
ParseFloat() - method parses a string value and returns the number with its decimal value.
-
.toString() - method converts a numeric value into a string.
-
.toExponential() - converts a number into a string and returns it in an exponential format.
-
toFixed() - method rounds up a number to the nearest highest or lowest fixed-point notation.
-
.toPrecision() - returns the numeric value with a specific length. It takes an argument that signifies the length. If given without a specific length, the method returns the number as it is.
-
valueOf() - method is used to return the primitive value of the Number object you’re calling it on. Primitive types in JavaScript are number, string, bigint, symbol, undefined, null, and boolean.
-
toLocaleString() - method uses a local language format to convert a number and returns it as a string. It takes two arguments, locales and options , which defines the language of which conversion you want to use, and the behavior of the function.
-
.isInteger() - checks whether the given value is an integer and returns a boolean value.