JavaScript: Number Object

By Xah Lee. Date: . Last updated: .

Number is the value of the property key "Number" of the Global Object .

console.log( window.Number === Number );


Type of Number is a function.

console.log( typeof Number === "function" );


Parent of Number is Function.prototype.

console.log( Reflect.getPrototypeOf ( Number ) === Function.prototype );


Purpose of Number is:

Number Primitive and Number Object

Literal numbers such as 3 are Primitive Value. That is, the type of a number such as 3, is number, not object.

Number primitive include special literal expression NaN and Infinity .

You can convert a primitive number type to a number object type by new Number(num).

Number Constructor

Number Constructor



Value is NaN.

console.log( Number.isNaN( Number.NaN ) );

Value is -Infinity.

console.log( Number.NEGATIVE_INFINITY === -Infinity );

Value is +Infinity.

console.log( Number.POSITIVE_INFINITY === Infinity );

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));

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.

console.log( Number.MAX_SAFE_INTEGER === 9007199254740991 );

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).

console.log( Number.EPSILON === 2.220446049250313e-16 );

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.

console.log( Number.MIN_VALUE === 5e-324 );

The value is the largest positive finite value of the Number type, which is approximately 1.7976931348623157 × 10^308.

console.log( Number.MAX_VALUE === 1.7976931348623157e+308 );

JavaScript Number

BUY ΣJS JavaScript in Depth