Java Reference
In-Depth Information
Notice that the counter , timesTable , and writeString
variables are visible (as is this ).
Now look at the Watch Expressions pane. There are
currently no watch expressions, but you can add them
by simply clicking the add icon (the plus sign). Type the
variable name or expression you want to watch, and
press the Enter key.
Go ahead and create a watch expression for counter == 1 .
You'll see your expression followed by a colon and the
value of the expression. At this point in time, you should
see the following as shown in Figure 18-6:
figure 18-5  
counter == 1: true
If the watch is in scope, the expression's value is
displayed. If the variable is out of scope, you'll see
“not available.”
figure 18-6  
Although this information is helpful when you want to see what exactly is going on in your
code, it's not very helpful if you can't control code execution. It's impractical to set a breakpoint
and reload the page multiple times just to advance to the next line, so we use a process called
stepping .
Stepping through Code
Code stepping is controlled by four buttons in the upper‐right of
the developer tools (Figure 18-7).
Continue (shortcut key is F8): Its function is to continue
code execution until either the next breakpoint or the end of
all code is reached.
Step Over (F10): This executes the current line of code and
moves to the next statement. However, if the statement is a
function, it executes the function and steps to the next line
after the function call.
figure 18-7  
Step Into (shortcut key is F11): Executes the current line of code and moves to the next
statement. If the current line is a function, it steps to the first line of the function.
Step Out (Shift‐F11): Returns to the calling function.
Let's do some stepping; follow these steps:
1.
Step Into the code by clicking the icon or pressing F11. The debugger executes the currently
highlighted line of code and moves to the next line.
2.
Look at the value of writeString in the Scope Variables pane; it is "1 * 2 = 2" . As you
can see, the values displayed in the Watch tab are updated in real time.
 
Search WWH ::




Custom Search