JavaScript Number Properties

JavaScript Number Properties

Properties Description
EPSILON The difference between 1 and the smallest number greater than 1.
MAX_VALUE The largest number possible in JavaScript.
MIN_VALUE The smallest number possible in JavaScript.
MAX_SAFE_INTEGER The largest safe integer (253 - 1).
MIN_SAFE_INTEGER The smallest safe integer -(253 - 1).
POSITIVE_INFINITY Infinity (returned when overflow).
NEGATIVE_INFINITY Negative infinity (returned when overflow).
NaN “Non-numeric” values.

JavaScript EPSILON

Number.EPSILON It is the difference between the smallest floating-point number greater than 1 and 1.

Example

let x = Number.EPSILON;

Try It Yourself

Note

Number.EPSILON is a feature of ES6.

It does not work in Internet Explorer.

JavaScript MAX_VALUE

Number.MAX_VALUE It is a constant in JavaScript representing the largest possible number.

Example

let x = Number.MAX_VALUE;

Try It Yourself

Numeric properties cannot be used for variables

Numeric properties belong to JavaScript Number object.

These properties can only be accessed as Number.MAX_VALUE.

Using x.MAX_VALUE (where x is a variable or value) will return undefined:

Example

let x = 6;
x.MAX_VALUE

Try It Yourself

JavaScript MIN_VALUE

Number.MIN_VALUE It is a constant in JavaScript representing the smallest possible number.

Example

let x = Number.MIN_VALUE;

Try It Yourself

JavaScript MAX_SAFE_INTEGER

Number.MAX_SAFE_INTEGER Represents the largest safe integer in JavaScript.

Number.MAX_SAFE_INTEGER It is (253 - 1).

Example

let x = Number.MAX_SAFE_INTEGER;

Try It Yourself

JavaScript MIN_SAFE_INTEGER

Number.MIN_SAFE_INTEGER Represents the smallest safe integer in JavaScript.

Number.MIN_SAFE_INTEGER It is -(2^53 - 1).

Example

let x = Number.MIN_SAFE_INTEGER;

Try It Yourself

Note

MAX_SAFE_INTEGER and MIN_SAFE_INTEGER are ES6 features.

They do not work in Internet Explorer.

JavaScript POSITIVE_INFINITY

Example

let x = Number.POSITIVE_INFINITY;

Try It Yourself

Returned when overflow occurs POSITIVE_INFINITY:

let x = 1 / 0;

Try It Yourself

JavaScript NEGATIVE_INFINITY

Example

let x = Number.NEGATIVE_INFINITY;

Try It Yourself

Returned when overflow occurs NEGATIVE_INFINITY:

let x = -1 / 0;

Try It Yourself

JavaScript NaN - Not a Number

NaN It is a JavaScript reserved word used to represent an invalid number.

Example

let x = Number.NaN;

Try It Yourself

Example

Attempting arithmetic operations on non-numeric strings will result in NaN (Not a Number):

let x = 100 / "Apple";

Try It Yourself

Complete JavaScript Number Reference Manual

For a complete reference manual, please visit our full JavaScript Number Reference Manual.

The reference manual includes descriptions and examples of all Number object properties and methods.