
| The Math object is used for various forms of mathematical
calculations. It contains several properties that are standard
constants, such as pi = 3.14159…, as well as a large set of
methods that represent common trigonometric and algebraic functions. All
Math methods deal with floating-point numbers. Angles are expected to be
given in radians, not degrees.
The Math object is our first example of a static object. A static object is one that does not change. All of the slots in the Math object already have values. This makes perfect sense, since you cannot change the value of pi or invent a new meaning for the cos() function (not without creating chaos). The practical consequence of Math being static is that you never use new with Math; you always refer to the Math object directly. Math is the opposite of the String object. The String object has instances but no explicit object; the Math object has only itself, and no instances. Math Object Properties
Math Object Methods
|