Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

JavaScript Number object


May 06, 2021 JavaScript with HTML DOM Reference book


Table of contents


JavaScript Number object


Number object

The Number object is the wrapper object of the original value.

Number was created in the form of new Number().

Grammar

var num = new Number(value);

Note: If a parameter value cannot be converted to a number, NaN (non-numeric value) is returned.


Number object properties

Property Describe
constructor Returns a reference to the Number function that created this object.
MAX_VALUE The maximum number that can be represented.
MIN_VALUE The smallest number that can be represented.
NEGATIVE_INFINITY Negative infinity, returned on overflow.
NaN Non-numeric values.
POSITIVE_INFINITY positive infinity, returning the value when it overflows.
prototype Allows you to have the ability to add properties and methods to objects.

Number object method

method describe
toExponential(x) Convert the value of the object to an exponential count method.
toFixed(x) Convert the number to a string, and the result is a number of positioning numbers.
toPrecision(x) Format the numbers to the specified length.
toString() Convert numbers to strings and use the specified base.
valueOf() Returns the basic numeric value of a Number object.