OBJECT:
Number
new
Number(value)
The Number object is an object wrapper for primitive numeric
values, allowing for their manipulation. To create a Number object
use the Number constructor above. The following example creates
a Number object of the numeric value 5:
Code:
five = new Number(5)
The main reason for doing this is to be able to use the constant properties
for the Number object, although you can create one in order to
add properties to it. You can also convert any object to a number by
using the Number function.
PROPERTIES
constructor property
This property specifies the function that created the object's prototype.
See also the Object.constructor
property.
Syntax: object.constructor
MAX_VALUE property
This property represents the largest value possible in JavaScript. It
is a static property and hence always referred to as Number.MAX_VALUE,
and has a value of approximately 1.79769e+308. Numbers larger than this
are represented as infinity.
Syntax: Number.MAX_VALUE
MIN_VALUE property This property represents the smallest positive
number possible in JavaScript, and as a static property is always referred
to as Number.MIN_VALUE. Its value is 5e-324, and any value smaller
than that is converted to 0.
Syntax: Number.MIN_VALUE
NaN property
This read-only property represents the special value Not-a-Number, and
is always unequal to any other number (including 0) and to NaN itself.
As a static property, it is always referred to as Number.NaN.
Syntax: Number.NaN
NEGATIVE_INFINITY property
This static, read-only property is a special value representing negative
infinity, which is returned on overflow.
Syntax: Number.NEGATIVE_INFINITY
POSITIVE_INFINITY
property
This static, read-only property is a special value representing infinity,
which is returned on overflow.
Syntax: Number.POSITIVE_INFINITY
prototype property
This property represents the prototype for this object and allows you
to add methods and properties of your own. See also the Function.prototype
property.
Syntax: object.prototype
METHODS
toSource method
This method, which is usually called by JavaScript behind the scenes,
returns a string representing the source code of the Number object.
This method overrides the Object.toSource
method.
Syntax: object.toSource()
toString method
This method returns a string representing the Number object,
and is called by JavaScript whenever the code requires a string value.
The optional 'radix' parameter is an integer between 2 and 36 which
specifies the base to be used when representing numeric values. This
method overrides the Object.toString
method.
Syntax: object.toString([radix])
valueOf method
This method, which is usually called by Javascript behind the scenes,
returns the primitive value of a Number object as a number data
type. This method overrides the Object.valueOf
method.
Syntax: object.valueOf()
NOTE:
The Number object also inherits the watch
and unwatch methods from the
Object object.
|