Java Reference
In-Depth Information
Safari's Web Inspector looks a lot like Chrome's, doesn't it? That's because Chrome is built
using a heavily modified version of WebKit. The Scripts tab is much like Chrome's Sources
tab; you can see the code, watch expressions, call stack, scope variables, and breakpoints all at
one time.
Setting Breakpoints
Creating a breakpoint follows the same procedure in Web Inspector as Chrome: Click the line
number at which you want the debugger to break. Breakpoints in Web Inspector are denoted by
the same blue tag used in Chrome. Create one on line 12. The breakpoints' subsection lists the
breakpoints you create, and it displays the same information you expect it to.
adding Watches
In earlier versions, Web Inspector did not allow you to
add watches. But in Safari 5, you can create watches to
inspect variables and expressions. Simply click the Add
button to create your watch. Figure 18-30 shows the watch
counter == 1 when the debugger is paused on line 12.
figure 18-30  
To remove a watch, click the red X next to it.
Stepping through Code
The code‐stepping buttons are at the top of the right
panel and underneath the search box (see Figure 18-31).
These buttons perform the same functions as the other
browser tools. You have the Continue button, followed
by Step Over, then Step In, and finally Step Out.
Like Chrome and Firebug, Web Inspector updates
the page as you step through code. So you can see the
results as each line executes.
figure 18-31  
the Console
The console serves the same purpose as it does in the previous tools. You can check the value of a
variable by typing the variable and pressing the Enter key. You can also execute code in the context
of the current line of code. Try the “Changed on the Fly” example to see it in action.
summarY
In this chapter you looked at the less exciting part of coding, namely bugs. In an ideal world you'd
get things right the first time, every time, but in reality any code more than a few lines long is likely
to suffer from bugs.
You first looked at some of the more common errors, those made not just by JavaScript
beginners, but also by experts with lots of experience.
 
Search WWH ::




Custom Search