|Class constants:||E, LN10, LN2, LOG10E, LOG2E, PI, SQRT1_2, SQRT2|
|Functions:||abs(), acos(), asin(), atan(), atan2(), ceil(), cos(), exp(), floor(), log(), max(), min(), pow(), random(), round(), sin(), sqrt(), tan()|
The Math object is merely a single object owned by the Global Object and which cannot be instantiated. It has some named properties, some of which are functions while others are constants.
The prototype for the Math prototype object is the Object prototype object.
Although it cannot be instantiated, it does have a constructor which in turn has a prototype property. By adding functions to that prototype, you can extend the capabilities of the Math object. Several examples are provided in nearby topics to illustrate the addition of extra trigonometric and hyperbolic functions.
The Math object provides a collection of static constant values by way of properties belonging to the integral Math object. because the mathematical mechanisms of any application tend to be provided by the operating system, you should find that between different browsers on any particular platform, the values that these constants yield will be very consistent.
The ECMA standard lays down strict values for these properties and in general, the browser manufacturers try to comply - however, there is always the possibility that an implementation may use a non-compliant calculation.
However, it may not be quite so reliable across platforms. You might enumerate one of these constants as you are authoring and then hard code that value into your script. When that script is executed on another platform, even in the same browser, the internal mathematics support may yield a different value.
You should always refer to the static constants using their symbolic names rather than hard code a possibly platform dependant value into your script.
Math.sin(Math.PI/2) may not yield exactly 1
Math.cos(Math.PI) may not return precisely zero
Math.acos(0) may not return the same value as Math.PI
Math.SQRT1_2 may not be exactly equal to the reciprocal of Math.SQRT2
ECMA 262 edition 2 - section - 10.1.5
ECMA 262 edition 2 - section - 188.8.131.52
ECMA 262 edition 2 - section - 15.8
ECMA 262 edition 3 - section - 10.1.5
ECMA 262 edition 3 - section - 184.108.40.206
ECMA 262 edition 3 - section - 15.8