Team LiB   Previous Section   Next Section
Global the global object


JavaScript 1.0; JScript 1.0; ECMAScript v1



Global Properties

The global object is not a class, so the following global properties have individual reference entries under their own name. 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.


A numeric value that represents positive infinity.


The not-a-number value.


The undefined value.

Global Functions

The global object is an object, not a class. The global functions listed below 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( )."

decodeURI( )

Decodes a string escaped with encodeURI( ).

decodeURIComponent( )

Decodes a string escaped with encodeURIComponent( ).


Encodes a URI by escaping certain characters.


Encodes a URI component by escaping certain characters.

escape( )

Encodes a string by replacing certain characters with escape sequences.

eval( )

Evaluates a string of JavaScript code and return the result.

isFinite( )

Tests whether a value is a finite number.


Tests whether a value is the not-a-number value.

parseFloat( )

Parses a number from a string.

parseInt( )

Parses an integer from a string.

unescape( )

Decodes a string encoded with escape( ).

Global Objects

In addition to the global properties and functions listed above, the global object also defines properties that refer to all the other predefined JavaScript objects. All of these properties are constructor functions that define classes except for Math, which is a reference to an object that is not a constructor.


The Array( ) constructor.


The Boolean( ) constructor.


The Date( ) constructor.


The Error( ) constructor.


The EvalError( ) constructor.


The Function( ) constructor.


A reference to an object that defines mathematical functions.


The Number( ) constructor.


The Object( ) constructor.


The RangeError( ) constructor.


The ReferenceError( ) constructor.


The RegExp( ) constructor.


The String( ) constructor.


The SyntaxError( ) constructor.


The TypeError( ) constructor.


The URIError( ) constructor.


The 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. In client-side JavaScript, for example, the global object is a Window object and represents the web browser window within which the JavaScript code is running.


In 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";

See Also

Window in the client-side reference section; Chapter 4

    Team LiB   Previous Section   Next Section