A global reference to the global object...

 

Syntax

global // the global object

Parameters

Not applicable.

Return value

The global 'global' property is a reference to the global object.

Example

var bar = "kipper";
function foo() {
  var bar = "halibut";
  console(bar); // halibut
  console(global.bar); // kipper
}
(function(){ // https://warzone.atlassian.net/wiki/display/jsapi/Code+sandboxing
 
  var eventStartLevel; // oops, now we can't define global eventStartLevel from in here :(
 
  // oh, yes we can! :)
  global.eventStartLevel = function() {
    // code
  }
 
})();
Availability

This feature requires:

Contents

Jump to:

See also

Related articles:

  • object.addConst() – define a global constant (eg. from within a function)
  • Globals – global properties defined by Warzone JS API

Globals

Topics: