Core JavaScript

The Global Object

JavaScript has one object that holds all of the objects in the code. It also holds all of the events and other global elements of the web page. The object type for the global object is specified as Window.

GlobalObject.html

<!DOCTYPE html>
<html>
<head>
    <title>XoaX.net's Javascript</title>
</head>
<body>
    <script type="text/javascript" src="GlobalObject.js"></script>
</body>
</html>

GlobalObject.js

// This function just prints out the members of an object.
function PrintAnObject(qObject) {
  var iCount = 0;
  var sOutput = typeof(qObject)+": " + qObject.constructor.name + "<br />";
  for (var sProperty in qObject) {
    sOutput += "&nbsp;&nbsp;&nbsp;&nbsp;" + sProperty + ': ' + qObject[sProperty]+"<br />";
    ++iCount;
    if (iCount >= 15) {
      document.writeln(sOutput);
      document.writeln("&nbsp;&nbsp;&nbsp;&nbsp;...<br />");
      return;
    }
  }
}

// Print the members of the global object
PrintAnObject(this);
 

Output

 
 

© 2007–2025 XoaX.net LLC. All rights reserved.