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

debugger

概述

调用任何一个可用的调试器,如果没有调试器可用,则该语句没有任何效果.

语法

debugger;

例子

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

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

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

Paused at a debugger statement.

规范

Specification Status Comment
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.

浏览器兼容性

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes) (Yes) (Yes) (Yes)
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) (Yes) (Yes) (Yes) (Yes) (Yes)

相关链接

文档标签和贡献者

 此页面的贡献者: yenshen, teoli, ziyunfei
 最后编辑者: yenshen,