Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Typically a reference to the head object is not used because it is
implied. For example, in the browser environment, window.alert and alert() are essentially the same statement.
JavaScript fills in the blanks here. Because the window object (i.e., the head object) is the
last object checked in the scope chain for a value, the window object is essentially always implied.
Below, we leverage the alert() function
which is contained in the global scope.
<!DOCTYPE html><html lang="en"><body><script>
var foo = { // window is implied here, window.foo
fooMethod: function() {
alert('foo' + 'bar'); // window is implied here, window.alert
window.alert('foo' + 'bar'); /* window is explicitly used,
with the same effect */
}
}
foo.fooMethod(); // window is implied here, window.foo.fooMethod()
</script></body></html>