Test for watched expression
To begin test, open DevTools, go the Scripts Panel and then click this link: [begin test].
Perform the following steps, and note the expected results:
After clicking the link above, you should now be paused in the body of
the test method, thanks to the debugger
statement.
Add the following expressions to the "Watch Expressions" section of the
Scripts panel sidebar pane: "this
", "a
",
"b
", "c
" and "d
". Do NOT enter the quotes.
The values of the expressions as shown in the window should be
Object
for this
, undefined
for
the a
, b
, and c
variables, and a
value of ReferenceError: d is not defined
for the d
variable.
Note that the value for d
should not change for the life of
the test, as the variable d
is never introduced in the program.
Step through the code, and you'll see the values of a
,
b
, and c
change, as the variables are assigned.
Also note that as the scope changes due to the function invocation, values
will be changed to refer to their current scope. The this
expression will change when the method is invoked on the object constructed by
the test.
Click different stack frames in the Call Stack section to ensure the expressions change value appropriately as the current stack frame changes.