admin管理员组

文章数量:1323157

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() acplishes. 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.

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() acplishes. 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.

Share asked Aug 29, 2012 at 18:37 ClaudiuClaudiu 230k173 gold badges503 silver badges699 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 7

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.

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

    function something() {
        // do stuff
        debugger;
    }
    

You can set breakpoints in chrome developers tool as well as firebug in firefox and developer tool in ie 8 and above..

本文标签: javascript interactive debugging (equivalent of python39s pdbsettrace())Stack Overflow