O'Reilly logo

Learning JavaScript, 2nd Edition by Shelley Powers

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. Troubleshooting, Debugging, and Cross-Browser Issues

Up to this point, most of what I’ve shown you regarding JavaScript has been fairly simple to create and debug because the examples were contained within the same page as the HTML. For the rest of the book, though, the examples will become more complex, and they’ll start to introduce the built-in object models, including the Document Object Model (DOM). The increasing complexity and use of object model will require a debugger that allows you to minutely control JavaScript execution as well as more closely examine the objects your code is accessing.

In addition, beginning with Chapter 7, differences in browser JavaScript support will become more apparent. Though support for JavaScript has improved vastly since I first began using it 12 years ago, not all browsers support all of the functionality available in JavaScript. In addition, browser vendors are always testing new and future JavaScript enhancements, and it’s important to know when to use (and when not to use) a new feature.

Simple Ways to Debug

Long-time programmers may sneer at the approach, but one of the simplest debugging methods is to use some form of output functionality to check the values of variables after processing. Though more sophisticated debugging tools are available, this still is a simple way to check out the state and value of a variable during application processing.

With JavaScript, the simplest way to output information is with an alert window, ...

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