简体   繁体   English

是否可以在chrome调试器中操作返回值?

[英]Is it possible to manipulate the return value in the chrome debugger?

Google's Chrome browser has a nice feature which shows you the return value in the debugger before you step out of the function. 谷歌的Chrome浏览器有一个很好的功能,可以在您退出该功能之前向您显示调试器中的返回值。 It shows up in the Scope list in one of the debugger panes along with Watch , Call Stack , etc. It looks like this . 它显示在一个调试器窗格的Scope列表中以及WatchCall Stack等。 它看起来像这样

I'm curious if there's console access to this variable? 我很好奇是否有控制台访问此变量?

I frequently have a need to do something like this while debugging: 在调试时我经常需要做这样的事情:

<return>.filter(function(z) { return z >= 0; })

Or any other arbitrary way to understand whether the return value was what I was expecting. 或任何其他任意方式来了解返回值是否是我期待的。 Unfortunately, I can't find a way to refer to <return> in the console. 不幸的是,我找不到在控制台中引用<return>的方法。 I was hoping there was some variable like $_ that would give me access, but I haven't found look looking in the likely places . 我希望有一些像$_这样的变量可以让我访问,但我还没有找到可能的地方

I realize I can look at the <return> object as it appears in the Scope list but if the item is a large array or complex object, etc., I would prefer to type some code into the debugger while paused at a breakpoint to see if I'm getting what I expect. 我意识到我可以查看<return>对象,因为它出现在Scope列表中,但如果该项是一个大型数组或复杂对象等,我宁愿在调试器中键入一些代码,同时在断点处暂停以查看如果我得到了我的期望。

What I typically resort to is modifying my code to save the return value to a variable, and then reproducing the steps to get back to the breakpoint, but this is annoying. 我通常采用的是修改我的代码以将返回值保存到变量,然后再现步骤以返回到断点,但这很烦人。

Thoughts? 思考?

Store as Global Variable works in google chrome now, using Version 56.0.2924.87 . 使用Version 56.0.2924.87 ,将Store as Global Variable在Google Chrome中。

So, you step to the close brace of your function in the Sources tab, then context-click the Return Value , and choose Store as Global Variable . 因此,您在“源”选项卡中单步执行函数的近大括号,然后单击“ 返回值”上下文,并选择“ Store as Global Variable

The console tab will show something like 控制台选项卡将显示类似的内容

temp1 = ▶ MyClass {...}

From there on you can access temp1 just like any other variable in the console. 从那里开始,您可以像控制台中的任何其他变量一样访问temp1。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Chrome调试器中检查JavaScript函数返回值? - How to inspect JavaScript function return value in Chrome debugger? Chrome调试器中的这个十六进制值是多少? - What is this hex value for in the Chrome debugger? 是否可以避免中断 Chrome 中的调试器语句? - Is it possible to avoid breaking on a debugger statement in Chrome? 是否可以检测 chrome 远程调试器或启用自动化 - Is it possible to detect chrome remote debugger or automation enabled 可以判断两个对象在Chrome调试器中是否相同? - Possible to tell if two objects are the same in Chrome debugger? 是否可以让Chrome返回CSS“内容”属性的原始值? - Is it possible to make Chrome return raw value of the CSS “content” property? chrome JavaScript调试器:如何输入值并查看? - chrome javascript debugger: how to enter value and see it? Chrome扩展程序:是否可以找出“ debugger”语句是否存在? - Chrome Extension: Is it possible to find out if 'debugger' statement exists? 在源调试器中是否可以看到chrome控制台? - Is it possible to see chrome console while being in source debugger? 是否可以通过Firefox和Chrome中的调试器更新javascript方法? - Is it possible to update a javascript method via debugger in firefox and chrome?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM