Investigating advanced debugging
Becoming a skilled debugger can be the difference between fixing a bug in 5 minutes or 5 hours. Knowing how to step through code, inspect it at various points, and find that little copy and paste error you (or someone else!) injected is critical to being successful. Let's discuss a few strategies that you can use to be more successful.
Breakpoints
One of the most useful things you can use while debugging is a breakpoint.
To set a breakpoint, click on a line of code and hit F9 (or click in the margin to the left of the line number), and a red dot will appear. When the debugger reaches this line, it will stop and wait for your next command. Notice the breakpoint on line 14 in the following screenshot:
An advanced version of this technique is the conditional breakpoint. Set a breakpoint, right-click on it, and then click on Conditions (in Visual Studio Code and Visual Studio...