12.2. About Static Objects
Some core language objects act as if they were true static objects. The Math object is a good example; it contains a number of properties and methods that scripts use without ever having to peel off an instance of that object to do some math.
In contrast, the Date object is a static object that generates an instance of itself each time someone creates a new date:
var now = new Date( );
Most objects are either all static (Math) or completely suppress themselves from the scene once you create instances you work with (String, Array, Number). Only a few objects operate in both modes, depending on whether you need the data of an instance of the object or one of the static properties or methods. You've seen how the Date object performs double duty. The RegExp object also performs this double duty; a regular expression instance object is created for you when you execute a related method. At the same time, you can access static objects (such as String and Array) to modify their basic behavior by assigning new properties and methods to their prototype (via the prototype property). New instances of such modified objects inherit the new properties or methods assigned to the prototype.
Copyright © 2003 O'Reilly & Associates. All rights reserved.