debugger 语句调用任何可用的调试功能，例如设置断点。 如果没有调试功能可用，则此语句不起作用。

## 语法

    debugger;

## 示例

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

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

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

## 规范

Specification | Status | Comment
--- | --- | ---
ECMAScript Latest Draft (ECMA-262) Debugger statement | Draft |
ECMAScript 2015 (6th Edition, ECMA-262) Debugger statement | Standard |
ECMAScript 5.1 (ECMA-262) Debugger statement | Standard | Initial definition
ECMAScript 3rd Edition (ECMA-262) Debugger statement | Standard |
ECMAScript 1st Edition (ECMA-262) Debugger statement | Standard | Only mentioned as reserved word.

## 浏览器兼容

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.

Update compatibility data on GitHub

| Desktop | Mobile | Server
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | Safari on iOS | Samsung Internet | Node.js
`debugger` | Chrome Full support Yes | Edge Full support Yes | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes

### Legend

Full support
  Full support

## 相关链接

- JavaScript调试
- 在火狐开发者工具中调试