JavaScript Number Methods
Many JavaScript Number methods are commonly used to manipulate number values. These number formats accept integers and floating-point numbers in decimal and hexadecimal notations.
Here are a few techniques for manipulating and modifying numerical values.
Method | Description |
---|---|
toString() | Converts a number to a string. |
toExponetial() | Convert a number into exponential notation. |
toFixed() | Formats a number with a specified number of decimal places. |
toPrecision() | Formats a number with a specified number of significant digits. |
ValueOf() | Returns the primitive value of a number. |
Number() | Convert a value to a number. |
parseInt() | Convert a string to an integer. |
parseFloat() | Convert a string to a floating-point number. |
Number.isInteger() | Determines whether a value is an integer or not. |
Number.isSafeInteger() | Determines whether a value is a safe integer or not. |
Number.parseFloat() | Convert a string to a floating-point number. |
Number.parseInt() | Convert a string to an integer. |
1. toString()
The toString() method is a built-in method in JavaScript that is used to convert a number to a string.
2. toExponential()
The toExponential() method is a built-in method in JavaScript that is used to Convert a number into exponential notation.
3. toFixed()
The toFixed() method is a built-in JavaScript method that is used to convert a number to a string and round the number to a specified number of decimal places.
4. toPrecision()
The toPrecision() method is a built-in JavaScript method that is used to convert a number to a string and format it to a specified number of significant digits.
5. ValueOf()
The valueOf() method is a built-in JavaScript method that returns the primitive value of an object.
6. Number()
The Number() function is a built-in function in JavaScript that can be used to Convert a value to a number.
7. parseFloat()
The parseFloat() function is a built-in function in JavaScript that is used to Convert a string to a floating-point number.
8. parseInt()
The parseInt() function is a built-in function in JavaScript that is used to convert a string to an integer.
9. Number.isInteger()
The Number.isInteger() is a built-in function in JavaScript that determines whether a value is an integer or not.
10. Number.isSafeInteger()
The Number.isSafeInteger() is a built-in function in JavaScript that determines whether a value is a safe integer or not.
11. Number.parseFloat()
The Number.parseFloat() is a built-in function in JavaScript that is used to convert a string to a floating-point number.
12. Number.parseInt()
The Number.parseInt() is a built-in function in JavaScript that is used to convert a string to an integer.