我想知道在任何浏览器中是否有一种方法可以在一段代码上设置断点,而不仅仅是在一行代码上。我正在尝试调试一些 JavaScript,在错误的行设置断点非常烦人,因为我不得不在断点上方添加或删除一行。所以我发现我经常需要在代码编辑后移动断点。
最佳答案
debugger
statement在 ECMAScript 5.1 中引入。
The debugger statement invokes any available debugging functionality, such as setting a breakpoint. If no debugging functionality is available, this statement has no effect.
console.log("Before breakpoint");
debugger;
console.log("After breakpoint");
关于javascript - 在代码而非行上设置断点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41090445/