Skip to content

Instantly share code, notes, and snippets.

@Integralist
Created January 11, 2012 08:45
Show Gist options
  • Save Integralist/1593770 to your computer and use it in GitHub Desktop.
Save Integralist/1593770 to your computer and use it in GitHub Desktop.
Details on Host Objects and how to list them

The easiest way to check what 'host' objects are available is to execute the following code:

var global = (function(){return this}()); // http://perfectionkills.com/unnecessarily-comprehensive-look-into-a-rather-insignificant-issue-of-global-objects-creation/

for (props in global) {
    console.log(props); 
}

The following is taken from Cody Lindley's "JavaScript Enlightenment"...

"As it pertains to web browsers, the most famous of all hosted objects is the interface for working with HTML documents, also known as the DOM. Below, is a method to list all of the objects contained inside the window.document object provided by the browser environment."

for (props in window.document) {
    console.log(props); 
}

"There is a dividing line between what JavaScript provides (e.g. JavaScript 1.5, ECMA-262, Edition 3 v.s. Mozilla's JavaScript) and what the host environment provides, and these two should not be confused.

The host environment (e.g. a web browser) that runs JavaScript code typically provides the head object (e.g. window object in web browser) where the native portions of the language are stored along with host objects (e.g. window.location in web browser) and user-defined objects (e.g. the code your write to run in the web browser).

It's not uncommon for a web browser manufacturer as the host of the JavaScript interrupter to push forward the version of JavaScript or add future specifications to JavaScript before they have been approved (e.g. Mozilla's Firefox JavaScript 1.6, 1.7, 1.8, 1.8.1, 1.8.5)."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment