JavaScript debugging with Chrome DevTools

Share on facebook
Share on twitter
Share on linkedin


Tracking down what happens in JavaScript code is not always trivial, especially when many event handlers and/or asynchronous ajax calls are involved. Using console.log in these cases can be tiresome and ineffective, in this article I am going to show the basics how to use Chrome DevTools for debugging JavaScript.

Getting started

Open the inspector (Cmd+Option+i or Ctrl+Shift+i), and navigate to the Sources tab, and choose the JavaScript file you want to debug on the navigation bar on the left hand side.

Add breakpoint by clicking on the line number:

Run the code in the browser, when the debugger stops, you can use the usual things to debug your code including:

  • Step into function – F11
  • Step over – F10
  • Step out of function call – Shift + F11
  • Watch variables
  • Inspect local variables


Additional useful features

I’ve recently learned some very handy features to use while debugging.


Adding debugger; command to the code the debugger stops executing the code, it is a very quick way to add a breakpoint, no need to browse the source files in the devtools.


Similar to the console.log, but it shows the variable as a table, useful to quickly check values of complex variables.

Pretty print

If you need to inspect/debug minified code (especially in production) devtools can pretty print the minified code by clicking on the curly braces in the bottom left corner of the main debugger window:

The pretty printed output is not as clean and useful than the original source code, but it is more understandable/debuggable than the minified version, it looks like this:

There are many more features of the devtools, if you are interested please check the official documentation here:

Subscribe to our newsletter

Be first to read new helpful post

Share this post with your friends

Share on linkedin
Share on xing
Share on twitter
Share on facebook

Communian – GO LIVE

In one of our previous blog posts we have announced Communian – an event platform for local communities, that will allow you to find interesting

Communian – COMING SOON

Update: We have launched on 19th November and we would like to invite you to check it out by registering. Find local communities of your

Leave a Reply

Notify of