最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Pausing code execution in chrome from within JS. Possible? - Stack Overflow

programmeradmin4浏览0评论

Can I pause execution from within JS code? I am working on a simple haxe-based debug util, and I want to be able to simulate breakpoints, by calling a util method which will trigger the execution pause.

Can I pause execution from within JS code? I am working on a simple haxe-based debug util, and I want to be able to simulate breakpoints, by calling a util method which will trigger the execution pause.

Share Improve this question asked Nov 20, 2011 at 9:23 user802232user802232 2,6117 gold badges37 silver badges41 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 17

Not sure if this is what you're looking for, but in Chrome (and Firefox if Firebug is installed) you can use the built-in JavaScript debugger statement. This causes the execution to pause, and is effectively like setting a breakpoint. For example, the following would break on every iteration of the loop allowing you to examine the value of i (stupidly simple example):

for(var i = 0; i < 10; i++) {
    debugger;
    console.log(i);
}
发布评论

评论列表(0)

  1. 暂无评论