`binding.pry` for javascript console? `binding.pry` for javascript console? ruby ruby

`binding.pry` for javascript console?


Try with debugger; in your code as this answer suggests. Your browser developer tools must be open.


Most browsers have developer tools that are quite similar to this.

In Chrome, for example, hit Ctrl+Shift+I to bring up the developer tools panel. Click on the "Sources" tab and you can browse any JavaScript files that have been loaded. From here you can set breakpoints by clicking in the left margin. Now when you reload the page, JavaScript execution will pause at the line you indicated.

At the bottom of the panel there is a "Show console" button that will open up a REPL you can play around with.

Here is a screenshot illustrating everything I just mentioned:

Screenshot of Chrome developer tools on StackOverflow

There are similar tools in Firefox, IE, Safari, and Opera. Just Google for "developer tools [your browser of choice]" to learn more about them.


I would like to mention that Node.js has a nice thing called Debugger.

Super short tutorial:

  1. is to run your app like this:

node debug appname.js

  1. instead of the usual

node appname.js

Do yourself a favor see: https://nodejs.org/api/debugger.html I posted this because I found lots of ways to do this that require dependancies before I found the debugger tool!