An IDE stands for an Integrated Development Environment. Not only can you write your code in an IDE, and compile it, it usually has different ways to debug your content.
How you debug will depend some based upon your IDE. VS Code has code built in debuggers for Type Script and JavaScript. Additional debuggers can be downloaded as an extension. While they will operate similarly, they may behave a little different.
We’re going to go through a series of commands which can help using VS Code.
Getting into Debug Mode
First, you should note that the Run Command, often has a drop down so it can do Run or Run and Debug (CTRL + SHIFT + D). If you Run and Debug, it will bring up information related to debugging your project that you don’t get if you just to Run your code. So what will it bring up?
Variables
You will typically see a list of all local and global variables. Not only will you see the variables, but their current values.
If variables are listed alphabetically, as they typically are, it makes it easy to find a variable that was defined accidentally by a misspelling. This is true for languages that don’t require you to define a variable before using such as JavaScript or Python. Obviously with languages like C/C++, Java, etc this can’t happen.
If you have hit a breakpoint, most IDEs that I’ve worked with will also let you hover over the variable to see it’s current value. This may be faster as you are probably looking at the code, and checking your logic at the same time, compared to having to look at a different panel for new information.
Call Stack
The call stack is the list of methods that were called so you can see what function or method was called from another source. This can help you ensure that methods are being called correctly, especially in external libraries, and help identify where an error occurred.
Run Time Control
During debug more, you can choose to either run your code normally, restart your code, pause playback, and if you have breaks in your code, you can choose to step into the code one line at a time, or continue on after running it.
Debugging within Your IDE was originally found on Access 2 Learn
One Comment
Comments are closed.