[英]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
列表中以及Watch
, Call 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.