Set watch expressions - Firefox Developer Tools 编辑

The Debugger Watch expressions pane allows you to specify JavaScript expressions that will be reevaluated and displayed every time the debugger pauses. As you step through code, the debugger will watch the expression and return any results. Watches are most commonly used to group individual variables of interest for easier observation. Watching more complicated expressions can sometimes also be useful: for example, to check that variables are within certain limits or values.

The screenshot below shows the Watch expressions panel with a number of expressions already defined. Each line shows the expression and its value at the current step, separated by a colon. Expressions that evaluate to an object can be expanded using the caret symbol to the left.

Screenshot showing the Watch expressions dialog after the + button has been pressed (for entry of a new watch expression)

To add a watch expression click the + button in the top right corner of the panel. Then type the expression into the text entry field that appears at the bottom of the panel, and press Enter to save it. The expression will be evaluated when you save, when you step through the code, or when you select the Refresh icon (next to +).

You can enter any valid expression into the watch, and even declare new "watch" variables and re-use them. For example, mywatchvar1 = 3 and mywatchvar2 = mywatchvar1 + 2 will evaluate mywatchvar2 as 5. You can also declare an expression that modifies a variable value in the code, and this will be re-evaluated whenever you step through the code or refresh the watch expression.

Important: Changing values in the code using a watch expression may affect normal code execution.

To remove a watch expression, select the X button that appears when you hover over a line.

Hover over watch expression to get X that can be clicked to remove an expression.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:77 次

字数:2563

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文