Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
JavaScript code, itself, must be contained within an object. As an
example, when crafting JavaScript code for a web browser environment,
JavaScript is contained and executed within the window object. This window object is considered to be the “head
object,” or sometimes confusingly referred to as “the global object.” All
implementations of JavaScript require the use of a single head
object.
The head object is set up by JavaScript behind the scenes to encapsulate user-defined code and to house the native code with which JavaScript comes prepackaged. User-defined code is placed by JavaScript inside the head object for execution. Let’s verify this as it pertains to a web browser.