Home >Web Front-end >JS Tutorial >Summary of Number methods in javascript
1. Constructor
Number(value)
new Number(value)
2. Number attribute
1. Number.MAX_VALUE Return the largest number that can be represented.
2. Number.MIN_VALUE The smallest number that can be represented.
3. Number.NAN Non-numeric value.
4. Number.NEGATIVE_INFINITY Negative infinity, returned when overflows.
5. Number.POSITIVE_INFINITY Positive infinity, returned when overflows.
3. Number method
1. toString() Use the specified base to convert a number into a string.
2. toLocaleString() Convert a number to a string in local number format.
3. toFixed() Convert a number to a string containing the specified number of decimal places.
4. toExponential() Convert a number to a string, using the specified number of valid digits.
5. valueOf() Return the original value of a Number object.
6. toExponential() Format a number using exponential notation
document.write(Number.MIN_VALUE + "<br/>"); //5e-324 document.write(Number.MAX_VALUE + "<br/>"); //1.7976931348623157e+308 document.write(Number.NaN + "<br/>"); //NaN document.write(Number.NEGATIVE_INFINITY + "<br/>"); //-Infinity document.write(Number.POSITIVE_INFINITY + "<br/>"); //Infinity var num = Number(5.123); //5.123 document.write(num.toString() + "<br/>"); //5.123 document.write(num.toFixed(2) + "<br/>"); //5.123 document.write(num.toPrecision(2) + "<br/>"); //5.123 document.write(num.valueOf() + "<br/>"); //5.123 document.write(num.toExponential(1)); //5.1e+0