
Variables assigned exactly at the breakpoint won’t be accessible. All the variables you can access are those that are global and local to the scope your breakpoint is in. We can type out the variables that interest us. At that point, we can start either use the GUI or the Debug Console to see our data. The program will run until it reaches a breakpoint. Select the language environment Evaluating The Results If you’re using the built-in run button, it will ask you to select the script you want to debug. You can execute the program like you would in your shell. Select the Node.js for Javascript, Typescript, express applications Running the Program JavaScript Debug Terminal will start the debugger when you run You’d have to set the language as node.js and pick the script you’d like to execute. Note: You can also use the start debug button. You can select/deselect them to turn them on/off.įirst, let’s create a Javascript debug terminal instance. You can see all the breakpoints set on the bottom-most Run & Debug panel. Note: The variables assigned at the breakpoint are not included in the scope. Set them anywhere after an assignment of a variable. Breakpoints will pause the execution of our code. Let’s add breakpoints to the lines where we want our program to stop. And this is all without having to write a single print statement in our code.

We often find ourselves adding a bunch of print statements to our code to understand what the heck is going on! Debuggers let us see the callers of functions and the state of local and global variables all in one place. Print statements don’t let us see the steps that occurred before a variable of interest. Javascript developers depend on print statements, sometimes to their detriment. It’s not a chore it’s a tool! On Javascript projects, making use of the VS Code debugger can speed up development a lot. Being dogmatic about console.log() only makes the development process longer.ĭon’t be like me and throw hours of work in the trash because you didn’t want to learn how to use your IDE’s debugger.

Have you ever sifted through hundreds of lines of text trying to figure out why a variable is null? If the answer is yes, you’ve heard of a debugger, right? If you’re like me, I don’t always take full advantage of the features my IDE offers me when I debug JavaScript. Let’s go beyond console.log() by learning how to debug JavaScript in VS Code.
