| Property | Description |
|---|---|
| MAX_VALUE | Returns the largest number possible in JavaScript |
| MIN_VALUE | Returns the smallest number possible in JavaScript |
| POSITIVE_INFINITY | Represents infinity (returned on overflow) |
| NEGATIVE_INFINITY | Represents negative infinity (returned on overflow) |
| NaN | Represents a "Not-a-Number" value |
JavaScript MIN_VALUE and MAX_VALUE
MAX_VALUE returns the largest possible number in JavaScript.
Example
var x = Number.MAX_VALUE;
MIN_VALUE returns the lowest possible number in JavaScript.
Example
var x = Number.MIN_VALUE;
JavaScript POSITIVE_INFINITY
Example
var x = Number.POSITIVE_INFINITY;
POSITIVE_INFINITY is returned on overflow:
Example
var x = 1 / 0;
JavaScript NEGATIVE_INFINITY
Example
var x = Number.NEGATIVE_INFINITY;
NEGATIVE_INFINITY is returned on overflow:
Example
var x = -1 / 0;
JavaScript NaN - Not a Number
Example
var x = Number.NaN;
NaN is a JavaScript reserved word indicating that a number is not a legal number.
Trying to do arithmetic with a non-numeric string will result in NaN (Not a Number):
Example
var x = 100 / "Apple"; // x will be NaN (Not a Number)
Number Properties Cannot be Used on Variables
Number properties belongs to the JavaScript's number object wrapper called Number.
These properties can only be accessed as Number.MAX_VALUE.
Using myNumber.MAX_VALUE, where myNumber is a variable, expression, or value, will return undefined:
Example
var x = 6;
var y = x.MAX_VALUE; // y becomes undefined
var y = x.MAX_VALUE; // y becomes undefined
Practice Excercise Practice now