Adding breakpoints to your code will make debugging much easier. The final tip that I will leave you with is the humble breakpoint. You can find more information about what can do in the debugger console, here. You can obviously use the debug console to do the same things as you could within the usual browser console tab. Instead of having to type out document.querySelector() you can use $ as a quick reference. The benefit of using the console to access elements is that you get access to a handy shortcut. You can't set a breakpoint on method signatures, declarations for a namespace or class, or variable declarations if there's no assignment and no getter/setter. For example, in the following C code, you could set a breakpoint on the line of code with the variable assignment (int testInt 1), the for loop, or any code inside the for loop. Once the debugger has launched and attached, you can also use it to query the element on the page. VS does not always correctly debug your client-side JavaScript breakpoints, but it works fine when using the debugger keyword: debugger var yourName. You can set a breakpoint on any line of executable code. Using console.log() isn't the only useful feature of the debug console. Get data from an API on page load, render it out here □□□ This technique can be useful when you don't want to leave VS-Code and you want to check data. In your debug console you should now see the output of your console.log statement. On the screen that pops up, click the 'Run and Debug' button. In the side ribbon, click on the 'Run and Debug' option, or, use the shortcut key Control + Shift + J. Next, log out some data using normal console.log() as can be seen below: Add a script tag and add some JavaScript to it. Luckily, debugging an HTML page that contains JavaSCript is super simple using VS Code.įirst, the best debugging tip is learning how to write to the debug console. Learning how to debug your code is an essential step to becoming a coding legend □□□♂️□□□□. In this tutorial, you will learn how to use the Visual Studio Code debugger.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |