24.90. Global: the global objectECMAScript v1: Object Global24.90.1. Synopsisthis 24.90.2. Global PropertiesThe global object is not a class, so the following global properties have individual reference entries under their own names. That is, you can find details on the undefined property listed under the name undefined, not under Global.undefined. Note that all top-level variables are also properties of the global object:
24.90.3. Global FunctionsThe global object is an object, not a class. The global functions listed here are not methods of any object, and their reference entries appear under the function name. For example, you'll find details on the parseInt( ) function under parseInt( ), not Global.parseInt( ):
24.90.4. Global ObjectsIn addition to the global properties and functions listed earlier, the global object also defines properties that refer to all the other predefined JavaScript objects. All these properties are constructor functions that define classes except for Math, which is a reference to an object that is not a constructor:
24.90.5. DescriptionThe global object is a predefined object that serves as a placeholder for the global properties and functions of JavaScript. All other predefined objects, functions, and properties are accessible through the global object. The global object is not a property of any other object, so it does not have a name. (The title of this reference page was chosen simply for organizational convenience and does not indicate that the global object is named "Global"). In top-level JavaScript code, you can refer to the global object with the keyword this. It is rarely necessary to refer to the global object in this way, however, because the global object serves as the top of the scope chain, which means that unqualified variable and function names are looked up as properties of the object. When JavaScript code refers to the parseInt( ) function, for example, it is referring to the parseInt property of the global object. The fact that the global object is the top of the scope chain also means that all variables declared in top-level JavaScript code become properties of the global object. The global object is simply an object, not a class. There is no Global( ) constructor, and there is no way to instantiate a new global object. When JavaScript is embedded in a particular environment, the global object is usually given additional properties that are specific to that environment. In fact, the type of the global object is not specified by the ECMAScript standard, and an implementation or embedding of JavaScript may use an object of any type as the global object, as long as the object defines the basic properties and functions listed here. For example, in JavaScript implementations that allow the scripting of Java via LiveConnect or related technologies, the global object is given the java and Packages properties and the getClass( ) method listed here. And in client-side JavaScript, the global object is a Window object and represents the web browser window within which the JavaScript code is running. 24.90.6. ExampleIn core JavaScript, none of the predefined properties of the global object are enumerable, so you can list all implicitly and explicitly declared global variables with a for/in loop like this: var variables = "" for(var name in this) variables += name + "\n"; 24.90.7. See AlsoWindow in Part IV ; Chapter 4 |