Global in ECMAScript 262

The global object

For more information see

Instance Properties

name type description
Infinity Infinity The static value "Infinity"
NaN NaN Not a Number
undefined undefined The static value "undefined"

Instance Methods

name returns description
eval(str) (none) Evaluate the supplied string as ECMAScript code.
isFinite(num) Boolean Returns false if the supplied number is NaN, Infinity or -Infinity; returns true otherwise.
isNaN(num) Boolean Returns true if the supplied number is NaN, false otherwise.
parseFloat(string) Number Attempt to convert a string into a number.
parseInt(string,[radix]) Number Attempt to convert a string into an integer number, using the specified base.


In web browsers, the Global object has a properties named 'window' and 'self' which refer to the Global object. The default 'window' object hence has all the properties of the Global object.

To create your own reference to the Global object in a UA which doesn't have such a convenience property, simply assign this to a new global variable outside the scope of any function, object, or event handler. For example:

<script type="text/ecmacript"><![CDATA[
    var Global = this;

If you're already trapped inside of a non-global scope, you can create and run a private function (which runs in global scope) to return the global scope:

var global = (function(){ return this })();