Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript interactive debugging (equivalent of python's pdb.set_trace())

I'm working with some javascript code and I'd love to be able to get an interactive console running in the context of a function call - that is, basically exactly what python's import pdb; pdb.set_trace() accomplishes. Is there any way to do this? If not, what's the best approximation out there?

I'm currently using Chrome's console to mess around with things, and I'd basically love to be dropped into the middle of a function call and use Chrome's console to poke around the local variables and such.

like image 466
Claudiu Avatar asked Aug 29 '12 18:08

Claudiu


1 Answers

Set a breakpoint, and Chrome's Inspector will allow you to inspect your app's state.

  • Click the line number. A blue marker will appear. Execution will pause when you hit that line. Breakpoint set

  • Write a debugger statement in your code. The Inspector will pause when you hit the statement.

    function something() {
        // do stuff
        debugger;
    }
    
like image 75
josh3736 Avatar answered Sep 20 '22 06:09

josh3736