Quick Guide to Debugging in Javascript
I have been working on Stephen Grider’s Javascript Udemy course, The Coding Interview Bootcamp: Algorithms + Data Structures, and there is a helpful part in the course where he talks about the basics of how to debug as you are working on solving the different algorithms in his course. I wanted to create this quick guide breaking down the steps of how to do it here.
- Place the debugger statement in your code where you would like it to be paused.
2. Make sure if the debugger is in a function to call the function.
3. Launch your javascript file in debugger mode by using the terminal to navigate to the directory the file is in and running node inspect your-file-name.js. It will pause its execution on the very first line of the file.
Get Jordan Martin’s stories in your inbox
Join Medium for free to get updates from this writer.
4. Tell the inspect to continue running the code by typing c (or cont). It will then execute the file line by line and pause once it finds the first debugger statement.
5. Enter the REPL mode to start a Javascript console by typing repl.
6. Test out your code! You are now in a Javascript console and can check the value of variables or run later written code to make sure you are getting the results you expect.
7. Exit REPL mode by hitting control + c. If needed, you can move on to the next debugger by entering c (or cont) repeating steps 4–6. If the code runs until the end then you can hit control + c again to exit the debugger mode.







