04.11.2015 Views

javascript

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 14: Error Handling and Debugging<br />

sign appears next to it that, when clicked, shows all of the properties and methods of the object. An<br />

object value can also be clicked in the Watch tab to inspect the object closer. When an object value is<br />

clicked, it opens the DOM tab, which lists all of the properties and methods of the object in a wider view.<br />

Watches<br />

Watches are added by clicking on the yellow area at the top of the Watch tab and typing in a variable<br />

name. When a watch is added, it is displayed with a gray background at the top of the Watch tab, and<br />

local variables are displayed with white backgrounds beneath it. Whenever the watch is in scope, the<br />

variable ’ s value is filled in appropriately; when the variable is out of scope, an error is displayed for the<br />

value. Moving your cursor over a watch reveals a red X button that can be used to delete the watch. See<br />

Figure 14 - 22 .<br />

Figure 14-22<br />

In Figure 14 - 22 , there are two watches: type and window . They are at the top of the Watch tab, and the<br />

local variables appear beneath them. Note that the local variable type and the watch type are both<br />

inspecting the same variable.<br />

The JavaScript Console<br />

The JavaScript console is on the Console tab as opposed to the Script tab on which the debugger resides. The<br />

console was used earlier in the chapter to output messages, but it can also be used as a command line for<br />

running JavaScript code within the context of the page. You need only type in some JavaScript code and<br />

press Enter to execute any arbitrary code and see the result output on the console. See Figure 14-23 .<br />

505

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!