aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/statements/debugger/index.html
blob: d87e77bfb845277e1824523e01b5ea344a5efeea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
---
title: debugger
slug: Web/JavaScript/Reference/Statements/debugger
tags:
  - JavaScript
  - Statement
translation_of: Web/JavaScript/Reference/Statements/debugger
---
<p>{{jsSidebar("Statements")}}</p>

<p><strong>debugger 语句</strong>调用任何可用的调试功能,例如设置断点。 如果没有调试功能可用,则此语句不起作用。</p>

<h2 id="语法">语法</h2>

<pre class="syntaxbox"><code>debugger;</code>
</pre>

<h2 id="示例">示例</h2>

<p>下面的例子演示了一个包含 debugger 语句的函数,当函数被调用时,会尝试调用一个可用的调试器进行调试。</p>

<pre class="brush:js  language-js">function potentiallyBuggyCode() {
    debugger;
    // do potentially buggy stuff to examine, step through, etc.
}</pre>

<p>当 debugger 被调用时, 执行暂停在 debugger 语句的位置。就像在脚本源代码中的断点一样。</p>

<p><a href="https://mdn.mozillademos.org/files/6963/Screen%20Shot%202014-02-07%20at%209.14.35%20AM.png"><img alt="Paused at a debugger statement." src="https://mdn.mozillademos.org/files/6963/Screen%20Shot%202014-02-07%20at%209.14.35%20AM.png" style="height: 371px; width: 700px;"></a></p>

<h2 id="规范">规范</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('ESDraft', '#sec-debugger-statement', 'Debugger statement')}}</td>
   <td>{{Spec2('ESDraft')}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName('ES6', '#sec-debugger-statement', 'Debugger statement')}}</td>
   <td>{{Spec2('ES6')}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName('ES5.1', '#sec-12.15', 'Debugger statement')}}</td>
   <td>{{Spec2('ES5.1')}}</td>
   <td>Initial definition</td>
  </tr>
  <tr>
   <td>{{SpecName('ES3', '#sec-7.5.3', 'Debugger statement')}}</td>
   <td>{{Spec2('ES3')}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName('ES1', '#sec-7.4.3', 'Debugger statement')}}</td>
   <td>{{Spec2('ES1')}}</td>
   <td>Only mentioned as reserved word.</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容">浏览器兼容</h2>

<p>{{Compat("javascript.statements.debugger")}}</p>

<h2 id="See_also">相关链接</h2>

<ul>
 <li><a href="https://developer.mozilla.org/en-US/docs/Debugging_JavaScript">JavaScript调试</a></li>
 <li><a href="https://developer.mozilla.org/en-US/docs/Tools/Debugger">在火狐开发者工具中调试</a></li>
</ul>