Latest web development tutorials

JavaScript Number Object

Number Object

Number object is a wrapper object original value.

Number way to create new Number ().

grammar

var num = new Number(value);

Note: If a parameter value can not be converted to a digital returns NaN (not a numeric value).


Number Object Properties

Attributes description
constructor Returns Number to create this object reference to a function.
MAX_VALUE The maximum number that can be represented.
MIN_VALUE The minimum number can be represented.
NEGATIVE_INFINITY Negative infinity, return the value overflow.
NaN Non-numeric values.
POSITIVE_INFINITY Positive infinity, return the value overflow.
prototype It allows you to have the ability to add properties and methods to an object.

Number Object

方法 描述
toExponential(x) 把对象的值转换为指数计数法。
toFixed(x) 把数字转换为字符串,结果的小数点后有指定位数的数字。
toPrecision(x) 把数字格式化为指定的长度。
toString() 把数字转换为字符串,使用指定的基数。
valueOf() 返回一个 Number 对象的基本数字值。