O'Reilly logo

The JavaScript PocketGuide by Lenny Burdette

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

7. The Global Object

In Chapter 5, you learned that all functions execute in a context that you can refer to with the this keyword. A simple function executed normally runs in the global context. In a browser, the global object is window.

image

When you learned about variable scope in Chapter 5, you learned that variables outside of functions are in the global scope. In fact, declaring a variable in the global scope is the same as making a property on the global object.

image

In Chapter 2, you learned about a few global functions such as isNaN() and parseInt() ...

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