Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt

A global reference to the global object...

 

Syntax

Code Block
themeRDark
languagejavascript
linenumberstrue
global // the global object

Parameters

Not applicable.

Return value

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

Example

Code Block
themeRDark
languagejavascript
titleReference a property of the global object/scope
linenumberstrue
var bar = "kipper";
function foo() {
  var bar = "halibut";
  console(bar); // halibut
  console(global.bar); // kipper
}
Code Block
themeRDark
languagejavascript
titleEasily access global from within enclosures/sandboxes
linenumberstrue
(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
  }
 
})();
Div
classbox
Availability
Status
colourGreen
titleStable

This feature requires:

Div
classbox
Contents

Jump to:

Table of Contents
maxLevel5

Div
classbox

See also

Related articles:

  • object.addConst() – define a global constant (eg. from within a function)
  • now – get current universal time in milliseconds since midnight 1st Jan 1970.
  • Globals – global properties defined by Warzone JS API
Div
classbox

Globals

Topics:

Child pages (Children Display)
alltrue
depthall
pageGlobals
excerpttrue