Curriculum
Course: JavaScript Basic
Login

Curriculum

JavaScript Basic

JSHome

0/216
Text lesson

JS Number Properties

JavaScript Number Properties

Property

Description

EPSILON

The discrepancy between 1 and the next smallest number greater than 1.

MAX_VALUE

The maximum number value achievable in JavaScript.

MIN_VALUE

The minimum number value attainable in JavaScript.

MAX_SAFE_INTEGER

The maximum safe integer in JavaScript, which is (2^53 – 1).

MIN_SAFE_INTEGER

The minimum safe integer in JavaScript, which is -(2^53 – 1).

POSITIVE_INFINITY

Infinity, which is returned in JavaScript when a calculation results in a value beyond the maximum representable number.

NEGATIVE_INFINITY

Negative infinity, which is returned in JavaScript when a calculation yields a value lower than the lowest representable number.

NaN

A value representing “Not-a-Number” in JavaScript.

JavaScript EPSILON

Number.EPSILON represents the smallest increment between two representable numbers greater than 1 and 1.

Example

let x = Number.EPSILON;

Note: Number.EPSILON is a feature introduced in ES6. 

However, it is not supported in Internet Explorer.

JavaScript MAX_VALUE

Number.MAX_VALUE is a constant that denotes the maximum achievable number in JavaScript.

Example

let x = Number.MAX_VALUE;

Number Properties Cannot be Used on Variables

JavaScript Number properties are specific to the Number Object.

They can solely be accessed in the format Number.MAX_VALUE.

Attempting to access them via x.MAX_VALUE, where x is a variable or a value, will result in undefined.

Example

let x = 6;
x.MAX_VALUE

JavaScript MIN_VALUE

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

Example

let x = Number.MIN_VALUE;

JavaScript MAX_SAFE_INTEGER

The value represented by Number.MAX_SAFE_INTEGER in JavaScript is (253 – 1).

Example

let x = Number.MAX_SAFE_INTEGER;

JavaScript MIN_SAFE_INTEGER

The value denoted by Number.MIN_SAFE_INTEGER  in JavaScript is -(253 – 1).

Example

let x = Number.MIN_SAFE_INTEGER;

Note

MAX_SAFE_INTEGER and MIN_SAFE_INTEGER are features introduced in ES6. 

They are not supported in Internet Explorer.

JavaScript POSITIVE_INFINITY

Example

let x = Number.POSITIVE_INFINITY;

Overflow results in the return of POSITIVE_INFINITY.

let x = 1 / 0;

JavaScript NEGATIVE_INFINITY

Example

let x = Number.NEGATIVE_INFINITY;

Overflow results in the return of NEGATIVE_INFINITY.

let x = –1 / 0;

JavaScript NaN – Not a Number

NaN is a reserved keyword in JavaScript used to represent a value that is not a valid number.

Example

let x = Number.NaN;

Performing arithmetic operations with a non-numeric string will lead to NaN (Not a Number) as the result.

let x = 100 / “Apple”;