O'Reilly logo

JavaScript® Programmer's Reference by Alexei White

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. The Global and Object Objects

The best way to learn a programming language is to master all the low-level concepts and gradually work your way up. Before I start talking in earnest about things like object-oriented development, windows, forms, and so on, I should introduce two more of these low-level ideas that come up over and over in JavaScript. One of these is the Global object, the parent construct to which all other objects, variables, and functions belong. The other is the Object object, the base class inherited by all other objects in the language, including the built-in objects. Once you understand how these things work, it will complete your understanding of the other features in JavaScript behave.

Features of the Global Object

The global object is the top-most context that all other objects belong to. It has certain properties and functions that you can rely on to build your applications. It also serves an important role in web development—being the upper-most context for scoping and also sharing the stage with some very high-level browser features you will come to rely on. Among other things, the global object contains:

  • All the built-in objects in JavaScript like String, Number, Math, and so on.

  • Several built-in properties that you use from time to time in the language.

  • Several built-in functions.

  • Several browser-specific objects such as the document, and window.

It also serves a useful purpose in scoping. When a variable is referenced but not found, the interpreter ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required