Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 535327 of debugger

  • Revision slug: Web/JavaScript/Reference/Statements/debugger
  • Revision title: debugger
  • Revision id: 535327
  • Created:
  • Creator: Havvy
  • Is current revision? No
  • Comment

Revision Content

Summary

Invokes any available debugging functionality. If no debugging functionality is available, this statement has no effect.

Version Information

Statement
Implemented in JavaScript 1.0
ECMAScript Edition ECMA-262 5th Edition

Syntax

debugger;

Examples

The following example shows code where a debugger statement has been inserted, to invoke a debugger (if one exists) when the function is called.

function potentiallyBuggyCode() {
    debugger;
    // do potentially buggy stuff to examine, step through, etc.
}

When the debugger is invoked, execution is paused at the debugger statement. It is like a breakpoint in the script source.

Paused at a debugger statement.

See also

Revision Source

<h2 id="Summary" name="Summary">Summary</h2>
<p>Invokes any available debugging functionality. If no debugging functionality is available, this statement has no effect.</p>
<h2 id="Version_Information">Version Information</h2>
<table class="standard-table">
 <tbody>
  <tr>
   <td class="header" colspan="2">Statement</td>
  </tr>
  <tr>
   <td>Implemented in</td>
   <td>JavaScript 1.0</td>
  </tr>
  <tr>
   <td>ECMAScript Edition</td>
   <td>ECMA-262 5th Edition</td>
  </tr>
 </tbody>
</table>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="syntaxbox">
<code>debugger;</code></pre>
<h2 id="Examples" name="Examples">Examples</h2>
<p>The following example shows code where a debugger statement has been inserted, to invoke a debugger (if one exists) when the function is called.</p>
<pre class="brush:js">
function potentiallyBuggyCode() {
    debugger;
    // do potentially buggy stuff to examine, step through, etc.
}</pre>
<p>When the debugger is invoked, execution is paused at the debugger statement. It is like a breakpoint in the script source.</p>
<p><a href="https://mdn.mozillademos.org/files/6963/Screen Shot 2014-02-07 at 9.14.35 AM.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="width: 700px; height: 371px;" /></a></p>
<h2 id="Examples" name="Examples">See also</h2>
<ul>
 <li><a href="/en-US/docs/Debugging_JavaScript">Debugging JavaScript</a></li>
</ul>
Revert to this revision