JS: 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 ); // true

Number is a function.

〔►see JS: Data Types

// type of Number
console.log ( typeof Number === "function" ); // true
console.log ( Object.prototype.toString.call (Number) === "[object Function]" ) // true

The parent of Number is Function.prototype. 〔►see JS: Prototype and Inheritance

// parent of Number
console.log ( Object.getPrototypeOf ( Number ) === Function.prototype ); // true

The purpose of Number is:

  1. Implicitly called by JavaScript to work on number type values. e.g. toString. (by first converting a number primitive value to a number object then call toString.)
  2. Has useful value properties (constants, such as Number.MAX_VALUE) and function properties.
  3. Has the property key "prototype" that is the parent object of number object. It has properties such as toFixed.

Number Primitive and Number Object

Numbers in JavaScript are primitive values. That is, the type of a number is number, not object.

〔►see JS: Data Types

Number primitive include special literal expression NaN and Infinity.

〔►see JS: NaN

〔►see JS: Infinity

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

〔►see JS: Number Constructor

Number Constructor

〔►see JS: Number Constructor


Function Properties

  1. Number.parseInt (ES2015)
  2. Number.parseFloat (ES2015)
  1. Number.isFinite (ES2015)
  2. Number.isInteger (ES2015)
  3. Number.isNaN (ES2015)
  4. Number.isSafeInteger (ES2015)

Value Properties

  1. Number.prototype
  1. Number.NaN
  1. Number.MIN_SAFE_INTEGER (ES2015)
  2. Number.MAX_SAFE_INTEGER (ES2015)
  1. Number.EPSILON (ES2015)
  2. Number.MIN_VALUE
  3. Number.MAX_VALUE


〔►see JS: Number.prototype

Number.parseInt ( string, radix )

〔►see JS: Number.parseInt

Number.parseFloat ( string )

〔►see JS: Number.parseFloat

Number.isFinite ( number )

〔►see JS: Number.isFinite

Number.isInteger ( number )

〔►see JS: Number.isInteger

Number.isNaN ( number )

〔►see JS: Number.isNaN

Number.isSafeInteger ( number )

〔►see JS: Number.isSafeInteger


The value of Number.NaN is NaN.

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

ECMAScript® 2016 Language Specification#sec-number.nan


The value of Number.NEGATIVE_INFINITY is -Infinity.

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

ECMAScript® 2016 Language Specification#sec-number.negative_infinity


The value of Number.POSITIVE_INFINITY is +Infinity.

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


The value of Number.MIN_SAFE_INTEGER is -9007199254740991 (-(2^53-1)).

The value of Number.MIN_SAFE_INTEGER is the smallest integer n such that n and n - 1 are both exactly representable as a Number value.

); // -9007199254740991

ECMAScript® 2016 Language Specification#sec-number.min_safe_integer


The value of Number.MAX_SAFE_INTEGER is 9007199254740991. That is, (2^53 - 1).

The value of Number.MAX_SAFE_INTEGER is the largest integer n such that n and n + 1 are both exactly representable as a Number value.

); // 9007199254740991

ECMAScript® 2016 Language Specification#sec-number.max_safe_integer


The value of Number.EPSILON 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).

); // 2.220446049250313e-16

ECMAScript® 2016 Language Specification#sec-number.epsilon


The value of Number.MIN_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.

); // 5e-324

// that's 5 * 10^(-324)

ECMAScript® 2016 Language Specification#sec-number.min_value


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

console.log (
 ); // 1.7976931348623157e+308

ECMAScript® 2016 Language Specification#sec-number.max_value


ECMAScript® 2016 Language Specification#sec-number-objects

Number Topic

  1. JS: Number Object
  2. JS: Number Constructor
  3. JS: Number.prototype
Like what you read? Buy JavaScript in Depth