JS: Number Object
What is the Keyword “Number”
Number
is the value of the property key "Number"
of the Global Object
.
window.Number === Number
Type
Type of Number
is a function.
typeof Number === "function"
Parent
Parent of Number
is Function.prototype.
Reflect.getPrototypeOf ( Number ) === Function.prototype
Purpose
Purpose of Number
is:
- Implicitly called by JavaScript to convert a number Primitive Value to object type, so that you can call methods on numbers. e.g.
toString
. - Used as a namespace to hold static methods.
- Holds the property key
"prototype"
. Its value is the parent of all instance of number.
Number Constructor
Properties
Number.NaN
-
Value is NaN.
Number.isNaN( Number.NaN )
Number.NEGATIVE_INFINITY
-
Value is
-Infinity
.Number.NEGATIVE_INFINITY === -Infinity
Number.POSITIVE_INFINITY
-
Value is
+Infinity
.Number.POSITIVE_INFINITY === Infinity
Number.MIN_SAFE_INTEGER
-
Value is
-9007199254740991
(same as-(2^53-1)
).It's the smallest integer n such that n and n - 1 are both exactly representable as a Number value.
console.log(Number.MIN_SAFE_INTEGER === -9007199254740991); console.log(-9007199254740991 === -(2 ** 53 - 1));
Number.MAX_SAFE_INTEGER
-
Value is
9007199254740991
. Same as(2^53 - 1)
.It's the largest integer n such that n and n + 1 are both exactly representable as a Number value.
Number.MAX_SAFE_INTEGER === 9007199254740991
Number.EPSILON
-
Value is the difference between 1 and the smallest value greater than 1 that is representable as a Number value, which is approximately 2.2204460492503130808472633361816 x 10^(-16).
Number.EPSILON === 2.220446049250313e-16
Number.MIN_VALUE
-
The value is the smallest positive value of the Number type, which is approximately 5 × 10^(-324).
In the IEEE 754-2008 double precision binary representation, the smallest possible value is a denormalized number. If an implementation does not support denormalized values, the value of
Number.MIN_VALUE
must be the smallest non-zero positive value that can actually be represented by the implementation.Number.MIN_VALUE === 5e-324
Number.MAX_VALUE
-
The value is the largest positive finite value of the Number type, which is approximately 1.7976931348623157 × 10^308.
Number.MAX_VALUE === 1.7976931348623157e+308