本文介绍了是否有可能在Chrome调试器中操作返回值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谷歌的Chrome浏览器具有很好的功能,可以在您退出该功能之前向您显示调试器中的返回值。它显示在一个调试器窗格中的 Scope 列表中,以及 Watch , Call Stack 等。。

m好奇,如果有控制台访问这个变量?



在调试时,我经常需要这样做:

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



< return> 的方法。我希望有一些像 $ _ 这样的变量可以让我访问,但是我还没有找到看。



我知道我可以看看< return> 对象,因为它出现在范围列表中,但是如果该项目是大型数组或复杂对象等。我宁愿在断点处暂停时键入一些代码到调试器中,以查看我是否得到了我期望的结果。



我通常采用的方法是修改我的代码将返回值保存到一个变量,然后再现步骤返回到断点,但这很烦人。



想法?

解决方案

存储为全局变量现在可以在谷歌浏览器中使用,使用版本56.0.2924.87 。



因此,您在Sources选项卡中选择函数的大括号,t hen上下文点击 Return Value ,然后选择存储为全局变量。



控制台选项卡将显示如下内容:

  temp1 =▶MyClass {...} 



从那里开始,您可以像访问控制台中的任何其他变量一样访问temp1。


Google's Chrome browser has a nice feature which shows you the return value in the debugger before you step out of the function. It shows up in the Scope list in one of the debugger panes along with Watch, Call Stack, etc. It looks like this.

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. 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.

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.

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.

The console tab will show something like

temp1 = ▶ MyClass {...}

From there on you can access temp1 just like any other variable in the console.

这篇关于是否有可能在Chrome调试器中操作返回值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 23:13