A List of JavaScript Constants



Navigation Aids -- This Page        Navigation Aids -- This Topic        Navigation Aids -- This Site








Core JS Constant List



A List of JavaScript Constants
Constant Name Constant Value Description
Number.MAX_VALUE 1.7976931348623157 X 10308 A constant that holds the largest possible numeric value that can be represented.
Number.MIN_VALUE 5 X 10-324 A constant that holds the smallest possible numeric value that can be represented.
Number.NaN The special value NaN. Not-a-Number.
Number.NEGATIVE_INFINITY The special value -Infinity. A value that is too small to be represented; eg. MIN_VALUE - 1 would result in -Infinity.
Number.POSITIVE_INFINITY The special value Infinity. A value that is too large to be represented; eg. MAX_VALUE + 1 would result in Infinity.
Math.E 2.718281828459045 the base of the natural logarithms (Euler's constant)
Math.LN10 2.302585092994046 the natural logarithm of 10
Math.LN2 0.6931471805599453 the natural logarithm of 2
Math.LOG10E 0.4342944819032518 the base-10 logarithm of e (base-10 logarithm of Euler's constant)
Math.LOG2E 1.4426950408889633 the base-2 logarithm of e (base-2 logarithm of Euler's constant)
Math.PI 3.141592653589793 PI
Math.SQRT1_2 0.7071067811865476 the square root of ½ (one-half)
Math.SQRT2 1.4142135623730951 the square root of 2
Infinity Infinity a numeric value that represents positive infinity; property of the Global Object
-Infinity -Infinity a numeric value that represents negative infinity; property of the Global Object
NaN not a number a numeric value that represents a not-a-number value; property of the Global Object
undefined undefined the undefined value; property of the Global Object


Comments

In OOD terms we could call the Native Number constants class properties. The constants of the Native Number object and the Math object require the object name to precede the constant to access the property. The constants of the Global Object can be accessed merely by the name of the constant.

As a review, to use a class property, we must use the class name (Number) along with the property name joined together by the access operator (dot operator).

We are able to create our own constants with the const keyword. The const keyword is not standard ECMAScript, however, most modern browsers will accept it. These constants are read-only and can not be reassigned. They can be defined once globally (top level) and used throughout your program.



Top            

Rx4AJAX        About Us | Topic Index | Contact Us | Privacy Policy | 2008 This Site Built By PPThompson