Debugging JavaScript Code > Finding and fixing logical errors > Stepping through code

 

Stepping through code

You can step through your code to execute your statements one at a time and monitor their effects in your program. For example, you can step over an if condition and see if the program stops at the first line within the conditional statement or at the next executable line after the if statement.

When the debugger stops at a statement with a function call, you can check the function to make sure it executes correctly. If the function is correct, you can step out of it to allow the debugger to run until the function returns. The program will stop again at the next statement after the function call location. If you attempt to step into a statement that contains a nonstandard JavaScript function, the behavior will be that of stepping over.

To step over a statement:

Click the Step Over button at the top of the JavaScript Debugger window.

When the program stops at any statement (including those with a function call), you can step over that statement to continue and pause before the next statement.

To step into a function:

Click the Step In button at the top of the JavaScript Debugger window.

To step out of a function:

Click the Step Out button.

You can only use Step Out when the debugger is within a user-defined function. Stepping out causes the remaining statements in the function definition to be executed. The debugger will pause at the next statement.